Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay-Framework: ClassCastException occured : java.util.LinkedHashMap cannot be cast to models.Systems
    primarykey
    data
    text
    <p>I'm attempting to iterate a <code>List</code> of objects. like so.. </p> <pre><code>for(System s : usersSystems){ } </code></pre> <p>Where <code>usersSystems</code> is of type <code>List&lt;UserSystems&gt;</code>. <code>usersSystems</code> is a fairly simple class simply consisting of a constructor...</p> <pre><code>public UsersSystems(System system,int ID) { this.system = system; this.ID = ID; } </code></pre> <p>Assigning <code>usersSystems</code> is done by making it equal to <code>user.sources</code> which is initialized and given a default value in the <code>User</code> constructor. Below is my stacktrace. Why am I getting the above error and how do I correct it?</p> <pre><code>play.exceptions.JavaExecutionException: java.util.LinkedHashMap cannot be cast to models.Systems at play.mvc.ActionInvoker.invoke(ActionInvoker.java:227) at Invocation.HTTP Request(Play!) Caused by: java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to models.Systems at controllers.Start.starting(Start.java:40) at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:540) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:498) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:474) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:469) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:157) ... 1 more </code></pre> <p><strong>EDIT:</strong></p> <p><strong>UserSystem</strong></p> <pre><code>@Entity public class UsersSystem extends Model{ public int ID; public System system; public UsersSystem(System system, int ID) { this.source = source; this.ID = ID; } } </code></pre> <p><strong>SYSTEM</strong></p> <pre><code>@Entity public class System extends Model{ private String name; private int ID; public System(String name, int ID){ this.name = name; this.ID = ID; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload