2 Replies Latest reply on Nov 17, 2005 2:42 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

        • 1. Re: org.hibernate.MappingException: Unknown entity
          redijedi

          I may have figured it out partially. I had to completely and utterly simplify all of my files first. Of course, in the end the problem doesn't seem to be related. Apparently, entities (par files) are not hot deployable. Even though the console displays some deployment related information when hot deploying, the entities get screwed up. So, you have to shutdown JBoss, delete all your ejb3's that depend on the entities, delete all your client code that depend on the ejbs, then re-deploy all of the above. So much for ease of development.

          • 2. Re: org.hibernate.MappingException: Unknown entity
            redijedi

            I have confirmed that the problem is in the deployment order. Is this how it is supposed to be?