hi all,
The title isnt clear as i couldnt think of one but, i have an EJB project and am trying to play with JPA. To create the entity manager i am injecting it in via anotations
@PersistenceContext(unitName="testConnection")
private EntityManager em;
when i run a test qurey which i belive to be fine
Query userQuery = em.createQuery("SELECT u FROM TestUser u WHERE u.username = 'test' u.password = 'test'");
tu = (TestUser) userQuery.getSingleResult();
I get an exception which points toward the EJB not being able to create the entity manager. The strange thing is that when i run,
tu = (TestUser) em.find(TestUser.class, id);
It works fine
My project structure is
EAR
EJB
EJB Client
JPA
persistance.xml
and i guess this is the main problem
SEVERE: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName testConnection
The individual projects are currently linked using dependancys.
So any thoughts? Thanks Jon