1 Reply Latest reply on Nov 16, 2005 7:10 PM by redijedi

    org.hibernate.MappingException: Unknown entity

    redijedi

      I've been over this a hundred times in at least 20 different approaches. I don't know what happened, but my EJB3 entities stopped working. I now get org.hibernate.MappingException: Unknown entity all the time. If I reconfigure things I get other errors, but it never works.

      I have a .par file that has my User class. It is annotated properly and the persistence.xml file looks like:

      <entity-manager>
       <name>myManager</name>
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:com.me.dsn.myDsn</jta-data-source>
       <class>com.me.entities.User</class>
       <properties>
       <property name="hibernate.dialect"
       value="org.hibernate.dialect.SQLServerDialect" />
       <property name="hibernate.hbm2ddl.auto" value="none"/>
       </properties>
      </entity-manager>
      


      In my SLSB, I used to be able to call:

      Query q = em.createNamedQuery("UserSelect");
      q.setParameter("userId", Integer.valueOf(userId));
      User user = (User) q.getSingleResult();
      


      UserSelect is a NativeNamedQuery defined in my User entity. This suddenly and mysteriously stopped working...mybe my upgrade to SP1 had something to do with it. Using this call I get:

      15:48:23,625 INFO [STDOUT] javax.ejb.EJBException: null; CausedByException is:
       Named query not known: UserSelect
      


      So, I thought maybe something changed. I altered my SLSB code to:

      Query q = em.createNativeQuery("{call svc_user_select(:userId)}",User.class);
      q.setParameter("userId", Integer.valueOf(userId));
      User user = (User) q.getSingleResult();
      


      Now I get:

      15:50:17,794 INFO [STDOUT] javax.ejb.EJBException: null; CausedByException is:
       Unknown entity: com.me.entities.User
      


      Further in the stack trace it shows a org.hibernate.MappingException: Unknown entity error. There is no information more informative than this. However, I can see in the JBoss console that the enity deploys without error. Why is it unknown? I have been running around in circles chasing this error all day, literally! Any help would be GREATLY appreciated.

      Thanks,
      T