Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy does Hibernate's EntityManager.find() impl throw EntityNotFoundException?
    text
    copied!<p>JPA 2.0 <a href="http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#find%28java.lang.Class,%20java.lang.Object%29" rel="nofollow">javadoc</a> (and probably the spec) say that EntityManager.find() returns null when entity isn't found:</p> <blockquote> <p>the found entity instance or null if the entity does not exist</p> </blockquote> <p>Yet Hibernate's impl throws EntityNotFoundException instead. Why? Observed using Hibernate 3.6.8 and <a href="http://search.maven.org/#artifactdetails%7Corg.hibernate.javax.persistence%7Chibernate-jpa-2.0-api%7C1.0.1.Final%7Cjar" rel="nofollow">hibernate-jpa-2.0-api v1.0.1.Final</a></p> <blockquote> <p>javax.persistence.EntityNotFoundException: Unable to find bar.foo.Entity with id 144487 at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:137) at org.hibernate.event.def.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:320) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:277) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998) at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:779) at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:754)</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload