[
http://opensource.atlassian.com/projects/hibernate/browse/EJB-249?page=co...
]
Emmanuel Bernard commented on EJB-249:
--------------------------------------
I don't think the actual cause is the @Column(nullable=false).
Can you a minimal runnable test case where mobi.database.domain.Server with id 249 is
actually in the DB.
Query.getResultList() throws undocumented EntityNotFoundException
-----------------------------------------------------------------
Key: EJB-249
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-249
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Versions: 3.2.0.ga
Reporter: Koda Janh
I am issuing the query: "select user from " + User.class.getName() + " as
user"
and I am getting this stack-trace:
javax.persistence.EntityNotFoundException: Unable to find mobi.database.domain.Server
with id 249
at
org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:107)
at
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:143)
at
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:193)
at
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:101)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:846)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
I've tracked down the problem to a "@Column(nullable=false)". Specifically,
if one of the objects in the result-set contain a null field that is defined as
"nullable=false" then the above exception will occur.
This behavior should either be documented in the Javadoc or the implementation should be
changed to throw one of the declared exceptions instead. Also, the actual error message is
misleading in that the specified object *is* found, but it violates the constraints of the
ORM mapping.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira