[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-249) Query.getResultList() throws undocumented EntityNotFoundException

Koda Janh (JIRA) noreply at atlassian.com
Tue Nov 14 01:16:04 EST 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/EJB-249?page=comments#action_25266 ] 

Koda Janh commented on EJB-249:
-------------------------------

I don't have a testcase yet (I'll try generating one for you) but I suspect the following is going on:

- I invoke em.createQuery("select user from " + User.class.getName() + " as user").getResultList()

- Class User has a @ManyToOne relationship to class Server, so although loading a given User is an optional operation, loading the related Server is probably a mandatory operation somehow.

   Please see the attached log (log4j with hibernate=DEBUG logging level). It should give you more than enough information as to what is going on inside Hibernate's guts. Please let me know whether you still need a test case or whether this log file gives you enough information.

Thank you!

> 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
>  Attachments: stacktrace.txt
>
>
> 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.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list