1 Reply Latest reply on Apr 23, 2009 11:03 PM by Linnet S

    org.hibernate.hql.ast.QuerySyntaxException: ... is not mapped

    Linnet S Newbie

      Hi,


      I'm trying to implement Hibernate Criteria however I'm not returning any results. I think my entity is not be recognized.


      When I try to perform a basic query I get "14:37:19,105 ERROR [STDERR] org.hibernate.hql.ast.QuerySyntaxException: Reports is not mapped [select r from Reports r]" from the following:


      Query query = session.createQuery("select r from Reports r");

      In hibernate.cfg.xml:



      <session-factory name="hibernateSessionFactory">
      <property name="show_sql">true</property>
      <property name="connection.datasource">java:/#{project.name}DS</property>
      <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
      <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
      <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
      <property name="hbm2ddl.auto">create-drop</property>
      <property name="session_factory_name">java:/sessionFactory</property>
      …
      
      



      In components.xml:
       



      <persistence:hibernate-session-factory name="hibernateSessionFactory"/>
          
       <persistence:managed-hibernate-session name="session"
                               auto-create="true"
                 session-factory-jndi-name="java:/sessionFactory"/>
      



      My entity:


      @Entity
      @Table(name="REPORTS")
      @Name("reports")
      @Scope(ScopeType.EVENT)
      public class Reports implements Serializable
      {
          /** the id **/
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          @Column(name="ID")
          private Long id;
          
          @Column(name="RPT_NAME")
          private String name;
      …
      }




      I am trying to implement the query when a search is performed:


      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("queryManager")
      public class QueryManager implements QueryManagerLocal
      {
      
      @In
      Session session;
      
      public void performSearch()
      {
           Query query = session.createQuery("select r from Reports r");
           List queryResult = query.list();
           log.info("The size of result is " + queryResult.size());
      }
      
      }




      I can run the same query using entityManager with no problems.  Is there some other setting hibernate is looking for to map my entity?