Issue Type: Bug Bug
Affects Versions: 4.2.0.Final, 4.0.0.Final
Assignee: Unassigned
Created: 28/Jun/13 10:56 AM
Description:

I have a cached HQL query that is returning a list with all null values. I'm sorry for not including a test case, but I have already debugged the problem and can describe it in detail below.

A bug in hibernate occurs if you try to cache a HQL query that selects an @OneToOne property from a domain object.

The problem is in OneToOneType.disassemble() line 175 in verson 4.2.0. The OneToOneType.disassemble() method returns null, but most likely it should do something similar to what is done in ManyToOneType.disassemble(). I actually fixed the bug in my case by stealing code from ManyToOneType from the disassemble and assemble methods, but I'm pretty sure what I did will break other inverse OneToOne caes. When the OneToOneType.disassemble() method is called from StandardQueryCache.put() line 111, because OneToOneType.disassemble() returns null, then a null is incorrectly placed in the cache resulting in a list of null values being returned from the cache when retrieved later.

If, however, the property that you are selecting in your JPQL query is a @ManyToOne type then there is no problem at all. My work around for now is to use a @ManyToOne on my property instead, but that won't work in all cases, so I will be waiting for one of your smart engineers to fix this bug. Many thanks!

Environment: running on Oracle using Tomcat
Project: Hibernate ORM
Labels: hibernate query cache
Priority: Minor Minor
Reporter: John Jenson
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira