find « EntityManager « JPA Q&A





1. When to use EntityManager.find() vs EntityManager.getReference()    stackoverflow.com

I have come across a situation (which I think is weird but is possibly quite normal) where I use the EntityManager.getReference(LObj.getClass(), LObj.getId()) to get a database entity and then pass the ...

2. what is difference between EntityManager.find() and EntityManger.getReference()?    stackoverflow.com

Whats is the difference between

<T> T EntityManager.find(Class<T> entityClass, Object primaryKey) and 
<T> T EntityManager.getReference(Class<T> entityClass, Object primaryKey) 
? I think getReference returns entity if it is managed. and find returns entity if ...

3. Ejb3Configuration.addPackage() does not find entities    stackoverflow.com

I want to add known JPA entities programatically when creating EntityManagerFactory. So I have this sequence (Hibernate 3.6)

 Ejb3Configuration ejbConf = new Ejb3Configuration();
 ejbConf.configure("TestPU", null);
 ejbConf.addPackage("org.jboss.jawabot.irc.ent");
 ejbConf.addPackage("org.jboss.jawabot.irc.model");
 emf = ejbConf.buildEntityManagerFactory();
I also tried ...

4. EntityNotFoundException on EntityManager.find is against JPA    forum.hibernate.org

... Caused by: javax.persistence.EntityNotFoundException: Unable to find es.qrr.buda.dao.impl.jpa.user.UserEntity with id 1234321 at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:137) [:3.6.6.Final] at org.hibernate.event.def.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:320) [:3.6.6.Final] at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:277) [:3.6.6.Final] at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152) [:3.6.6.Final] at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090) [:3.6.6.Final] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005) [:3.6.6.Final] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998) [:3.6.6.Final] at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:614) [:3.6.6.Final] ...

5. EntityManager find() problem    forum.hibernate.org

Dear all, I have a Site bean that have a Warehouse (@OneToOne relationship) When I persist an instance of Site and find this instance sometimes the Warehouse relationship comes null and sometimes come whith value. Maybe is a session problems, beacause if I restart the application, the find never fails. Can anybody help me? tks,