5 Replies Latest reply on Sep 4, 2006 9:15 AM by Ikki da

    entity bean name in ejb3 RC7

    Micha? ?elechowski Newbie

      Hello!

      I have just migrated from JBoss4.0.3, EJB3 RC3 to JBoss 4.0.4, EJB3 RC7. My EAR project consists of two packages: logic.jar (previously .ejb3) with SLSB & SFSB, and data.jar (previously .par) with entity beans. After consulting wiki EJB migration guide, I deployed application to new server. When I try to execute following query:

      SELECT u FROM User AS u WHERE u.login= :login
      I got the following exception:

       javax.persistence.PersistenceException: org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [SELECT u FROM User AS u where u.login = :login]
      

      Which is strange, as User should be the enity bean name by the specification.
      When I put fully qualified name of the entity:
      SELECT u FROM myPackage.User AS u WHERE u.login= :login
      I got
       javax.persistence.PersistenceException: org.hibernate.HibernateException: could not locate named parameter [login]
      

      User entity is defined as:
      package myPackage;
      @Entity
      @Table(name = "APPLICATION_USERS")
      public class User implements Serializable
      {
      ...
      private String login;
      @Column(name = "USERNAME", nullable = false, unique = true)
       public String getLogin()
       {
       return this.login;
       }
      
      public void setLogin(String login)
       {
       this.login = login;
       }
      }
      

      persistence.xml is defined as:
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
       version="1.0">
       <persistence-unit name="MyEntityManager" transaction-type="JTA">
       <jta-data-source>java:/MyDS</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="none" />
       <property name="hibernate.dialect"
       value="org.hibernate.dialect.Oracle9Dialect" /> </properties>
       </persistence-unit>
      
      </persistence>
      

      I have put it into logic and data jars. Am I missing something?

      regards

      Micha?

        • 1. Re: entity bean name in ejb3 RC7
          Maurice Zeijen Master

          I am having the same problem. Somehow Hibernate can't find the entitity classes in a different ejb package within the same ear package. I would really like to now how to fix this.

          • 2. Re: entity bean name in ejb3 RC7
            Micha? ?elechowski Newbie

            I found something, which I unfortunatelly don't have to time to check right now. There should be line:

            ...
            <jta-data-source>java:/UMKDS</jta-data-source>
            <jar-file>../data.jar</jar-file>
            <properties>
            ...
            

            at persistence.xml, where data.jar is jar with entities. If you check it, I will appreciate if you could tell If it works.

            regards

            Michal

            • 4. Re: entity bean name in ejb3 RC7
              Maurice Zeijen Master

              I've tried it and it should work but it doesn't :( . There is a bug that incorrectly generates the wrong path to the jar file. I hope they fix this soon.

              I do however have a workaround. You can use the class property to list all the persistence classes that you want to have available in the persistence manager.

              Example:

              ...
              <jta-data-source>java:/MyDS</jta-data-source>
              <class>yPackage.User</class>
              <class>yPackage.SomeOtherEntity</class>
              <properties>
              ...
              


              It isn't really nice, but it works. I tested it.

              • 5. Re: entity bean name in ejb3 RC7
                Ikki da Newbie

                Hi,

                I am developing a seam application integrated with JBPM. I am using Seam 1.0.1.GA on Jboss 4.0.4.GA with JBPM 3.1 I have a combined persistnace for JBMP and my application objects.

                When I do a create query as follows:

                User found =
                (User) em.createQuery("from JBPM_ID_USER u where u.ID__ = :userName and u.PASSWORD_ = :password")
                .setParameter("userName", username)
                .setParameter("password", password)
                .getSingleResult();

                I get the following error:

                15:08:26,080 ERROR [STDERR] javax.persistence.PersistenceException: org.hibernat
                e.hql.ast.QuerySyntaxException: JBPM_ID_USER is not mapped [select NAME_ from JBPM_ID_USER]

                I have copied the jbpm-identity-3.1.jar into ejb3 folder for the ear
                have the following entires in the hibernate.cfg.xml

                mapping resource="org/jbpm/identity/User.hbm.xml"
                mapping resource="org/jbpm/identity/Group.hbm.xml"
                mapping resource="org/jbpm/identity/Membership.hbm.xml"

                I hve tried both the ways mentioned above,but both ways failed to solve the issue.

                Can anybody throw some light on this.

                Thanks,
                Ikram