Currently my project looks like:
Root
-- Common (Contains Entity classes)
-- Processor (Refers Common)
Common and Controller are both maven projects (each deployed in its own Jetty instance - common is user-facing jetty server and processor is back-end daemon that currently runs in jetty server too as it is designed for responding to some internal http-requests too). Root contains the parent pom for both Common and Processor
When I do DB related operations in Common, it works pretty well.
But when I call the same functions from Processor, it gives an error:
java.lang.IllegalArgumentException:
org.hibernate.hql.internal.ast.QuerySyntaxException:
User is not mapped [select users from User users fetch all properties]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1679)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1608)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:294)
at com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:129)
at com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:96)
at com.mysema.query.jpa.impl.AbstractJPAQuery.list(AbstractJPAQuery.java:248)
at com.myproject.common.persistence.UserManager.selectStar(UserManager.java:110)
UserManager.selectStar() works perfectly well from common though. Both Common and Processor have query-dsl plugin to generate Q-files. Both Common and Processor have META-INF/persistence.xml file too.
UserManager instantiates EntityManagerFactory as:
emf = Persistence.createEntityManagerFactory("world");
where "world" is the name of my DB.
./common/src/main/resources/META-INF/persistence.xml
./processor/src/main/resources/META-INF/persistence.xml
Processor has a dependency on common as:
<!-- language: lang-xml -->
<dependency>
<groupId>com.mock</groupId>
<artifactId>common</artifactId>
</dependency>
All dependency versions are also being managed in the Root pom's <dependencyManagement> section.