title: createQuery() does not give the result for select query
body: <p>I am going to develop a simple application using hibernate 4.3.x with using jsp and servlets. I want to load table data from database to a table created using jsp. </p>
  
  <p>Here is the required section in my <strong>role.jsp</strong> file</p>
  
  <pre><code> &lt;table class="table"&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;Role ID&lt;/th&gt;
          &lt;th&gt;Role Title&lt;/th&gt;
          &lt;th&gt;Actions&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;%
                       DBManager db = new DBManager();
                       List&lt;Role&gt; list = db.getListOfRoles();
                       for (Role r : list) {
                   %&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;%=r.getRid()%&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%=r.getRtitle()%&gt;&lt;/td&gt;
          &lt;td&gt;&lt;button type="button" class="btn btn-secondary" action="viewRoles.jsp"&gt;View&lt;/button&gt;
              &lt;button type="button" class="btn btn-secondary" action="updateRoles.jsp"&gt;Update&lt;/button&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;%}%&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  </code></pre>
  
  <p>Here is my pojo class called <strong>Role.java</strong> for representing Role object</p>
  
  <pre><code>package com.hrmweb.model;
  
  import java.io.Serializable;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import static javax.persistence.GenerationType.IDENTITY;
  import javax.persistence.Id;
  import javax.persistence.Table;
  import org.hibernate.annotations.GenericGenerator;
  
  @Entity
  @Table(name="ROLE")
  public class Role implements Serializable{
      @Id
      @GenericGenerator(name="gen",strategy="increment")
      @GeneratedValue(generator="gen")
      @Column(name = "rid", unique = true, nullable = false, precision = 15, scale = 0)
      private long rid;
      private String rtitle;
  
  
      public Role() {
      }
  
      public Role(String rtitle) {
          this.rtitle = rtitle;
          System.out.println(rtitle);
      }
  
      public long getRid() {
          return rid;
      }
  
       public void setRid(long rid) {
          this.rid = rid;
      }
  
      public String getRtitle() {
          return rtitle;
      }
  
      public void setRtitle(String rtitle) {
          this.rtitle = rtitle;
      }
  }
  </code></pre>
  
  <p>Here is the required part for database transactions in <strong>DBManager.java</strong> class</p>
  
  <pre><code> public List&lt;Role&gt; getListOfRoles(){
          List&lt;Role&gt; list = new ArrayList&lt;Role&gt;();
          Session session = HibernateUtil.openSession();
          Transaction tx = null;       
          try {
              tx = session.getTransaction();
              tx.begin();
              Query query = session.createQuery("from Role");
              List&lt;Role&gt; listCategories = query.list();
  
              System.out.println("Roles List : "+list.size());
              tx.commit();
          } catch (Exception e) {
              if (tx != null) {
                  tx.rollback();
              }
              e.printStackTrace();
          } finally {
              session.close();
          }
          return list;
      }
  </code></pre>
  
  <p><strong>hibernate.cfg.xml</strong> file</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
    &lt;session-factory&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.DerbyDialect&lt;/property&gt;
      &lt;property name="hibernate.connection.driver_class"&gt;org.apache.derby.jdbc.ClientDriver&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:derby://localhost:1527/test&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;test&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;test&lt;/property&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
      &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
      &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
      &lt;mapping class="com.hrmweb.model.user"/&gt;
      &lt;mapping class="com.hrmweb.model.Role"/&gt;
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>But when i'm executing my application it doesn't return any list of values through the createQuery() method. And also GlassFish server doesn't give any error message. So here is the server output.</p>
  
  <blockquote>
    <p>Info:   HHH000232: Schema update complete
    Info:   Hibernate: select role0_.rid as rid1_0_, role0_.rtitle as rtitle2_0_ from ROLE role0_
    Info:   Roles List : 0</p>
  </blockquote>
  
  <p>Here is my derby database hierarchy</p>
  
  <p><a href="https://i.stack.imgur.com/8Nnb0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Nnb0.png" alt="enter image description here"></a></p>
  
  <p>I'm very new to this environment and tried many ways. Please help me to solve this.</p>