title: Trying to create a List of user-defined objects, getting Object List
body: <p>This is my <code>user.java</code> domain class is</p>
  
  <pre><code>public class User {
  
  private Integer iduser;
  private String user_name;
  private String user_activation_key;
  private String user_password;
  private String user_email;
  private Character registered;
  
  public Integer getIduser() {
      return iduser;
  }
  
  public void setIduser(Integer iduser) {
      this.iduser = iduser;
  }
  
  public String getUser_name() {
      return user_name;
  }.....more code
  </code></pre>
  
  <p>And in a another Test class I have Coded as follow.</p>
  
  <pre><code>SQLQuery query = session.createSQLQuery("select * from user");
  List&lt;User&gt; availableUsers = new ArrayList&lt;User&gt;();
  availableUsers=(List&lt;User&gt;)query.list();
  </code></pre>
  
  <p><strong>query</strong> is a SQLQuery (Hibernate implementation) to get user list from DB.<br>
  But I can't cast the <code>(query.list)</code> to <code>List&lt;User&gt;</code>.<br>
  I'm getting  class cast exception. <code>availableUser</code> is a object list.<br>
  What steps should I follow.</p>