2 Replies Latest reply on Jan 18, 2007 7:58 AM by littlewing1112

    The persistence manager doesnt find EJB3 entities when testc

    littlewing1112

      Hello,
      I http://jira.jboss.org/jira/browse/JBSEAM-570 but gavin said this is not a bug so, that s my problem:

      The samples bundled (expecially BookingUnitTest) with the distribution work but not in my environment:
      1- I splitted the sample in order to "be mavenized" (I added the dependencies bundled in the release of seam in my repository (eg. jboss-third-party)
      2- I changed the database to postgreSQL
      3- add one more table
      4- move queries to namedqueries

      Maven separates classes build directory and test build directory.
      I have this directory layout:

      target/classes --> EJB builds
      target/test-classes
      /ejb-container
      testcases classes built
      /micro-container
      /resources files

      When I start a test which seems like BookingTest (in sample booking) everything works fine, but when I start BookingUnitTest, the persistencemanager doesnt find the entity

      I have this error:

      javax.persistence.PersistenceException: org.hibernate.hql.ast.QuerySyntaxException: Hotel is not map
      ped [from Hotel]
      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.
      java:567)
      at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:79)
      at org.jboss.seam.example.booking.test.BookingUnitTest.testHotelBooking(BookingUnitTest.java:61)
      Caused by: org.hibernate.hql.ast.QuerySyntaxException: Hotel is not mapped [from Hotel]
      at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:
      158)
      at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
      at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
      at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:267)
      at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3049)
      at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
      at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
      at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
      at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
      



      You http://jira.jboss.org/jira/secure/attachment/12313130/booking.tgz

      Thanks for your help!!

      Regards,
      Alexandre Touret



        • 1. Re: The persistence manager doesnt find EJB3 entities when t
          smokingapipe

          If you're getting "not mapped", the first place to look is to see if you're getting the correct entity manager. I was getting this problem and found out that (for obscure reasons) I wasn't getting the EntityManager I thought I was getting. I'm pretty sure that your unit test cotext is giving you the wrong EM.

          Is there some way to query an EntityManager (probably using getDelegate) to have it identify itself? Like have it say, "I map these tables, I'm using this DataSource, etc"?

          • 2. Re: The persistence manager doesnt find EJB3 entities when t
            littlewing1112

            I dont know how to specify the right entitymanager ?

            The only workaround I have found is to put all .class file in the same directory and not in target/test-classes and target/classes

            Should I put the ejb-container confi files in both ?

            Thanks in advance