]
Steve Ebersole updated HHH-3528:
--------------------------------
Assignee: Steve Ebersole
Fix Version/s: 3.4
3.3.x
3.2.x
FETCH JOIN query doesn't work in a StatelessSession
---------------------------------------------------
Key: HHH-3528
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3528
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.6, 3.3.1
Environment: Hibernate core 3.3.1 and 3.2.6, HSQLDB 1.8.0 and PostgreSQL 8.1
Reporter: Oscar Pearce
Assignee: Steve Ebersole
Fix For: 3.2.x, 3.3.x, 3.4
Attachments: slsession.zip, StatelessSessionImpl.patch
A query with an explicit JOIN FETCH, such as the following:
from DomainObject obj join fetch obj.a
fails when run in a StatelessSession, giving the following exception:
org.hibernate.SessionException: proxies cannot be fetched by a stateless session
at org.hibernate.impl.StatelessSessionImpl.immediateLoad(StatelessSessionImpl.java:243)
at
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:95)
at
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
at
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
The attached zip file contains a small project (buildable with maven) that demonstrates
the problem. Applying the patch to StatelessSessionImpl fixes it.
The cause of the problem is with the internalLoad method of StatelessSessionImpl. The
method currently first tries to generate a proxy and, only if no proxy is available, then
it uses the data that it loaded as part of the query. The patch changes it to use any
loaded data from the query in preference to creating a proxy. (I suspect that the check
for eager should be omitted, and that an exception should be thrown if getEntity fails and
no proxy can be created, but I don't know the code well enough to be sure of that.)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: