CDV ❯ hibernate query cache will throw IllegalArgumentException for lazy loaded fields
-
Bug
-
Status: Resolved
-
2 Major
-
Resolution: Fixed
-
Integration Modules
-
-
-
Reporter: asi
-
April 22, 2008
-
0
-
Watchers: 2
-
October 16, 2012
-
October 16, 2012
Attachments
Description
This forum reports this problem: http://forums.terracotta.org/forums/posts/list/930.page#5664
Hibernate set a field to LazyPropertyInitializer.UNFETCHED_PROPERTY when a field is lazily loaded for query cache. The hibernate code use reference equality to compare with this field to determine if it needs to reload the field. So, when the we share the query cache (such as using clustered ehcache), the equality between the DSO object and the hibernate object will return false.
Attached is a sample app to reproduce this problem from Nitin.
After discussing with Tim and Nitin, there are several options to this problem:
-
Make this field a root. Since this is a singleton field of an interface, we need to change our code to support root in an interface, since we currently skip instrumentation for interface. We also need to insturment all classes that is referring to this field so that it will call the getter method.
-
Change all references to this field to use .equals() method instead of reference equality.
-
Somehow, mark this field as a special literal object, and when we lookup an object of this type, use the singleton field of this type instead. In this case, we do not need to instrument classes that are referring to this field.
Currently, these are the classes which are referring to this field in hibernate 3.2.5:
org/hibernate/engine/ForeignKeys.java org/hibernate/engine/Nullability.java org/hibernate/engine/TwoPhaseLoad.java org/hibernate/event/def/AbstractVisitor.java org/hibernate/intercept/LazyPropertyInitializer.java org/hibernate/persister/entity/AbstractEntityPersister.java org/hibernate/pretty/Printer.java org/hibernate/tuple/entity/AbstractEntityTuplizer.java org/hibernate/type/TypeFactory.java
Comments
Fiona OShea 2008-04-23
njain 2008-04-26
No, I did create a temporary patch for customer verification. If I need to fix it, I will need some help from Engineering.
njain 2012-10-16
Not an issue anymore
Nitin do you have a fix ready for this?