I’m running Hibernate 5.2.15
When Object has
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
and property
@Lob
@Basic(fetch = FetchType.LAZY)
private byte[] file;
(also tried with @LazyGroup( “binaryGroup” ))
Results in
java.lang.IllegalArgumentException: Value was not an array [org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer$1]
at org.hibernate.type.descriptor.java.ArrayMutabilityPlan.deepCopyNotNull(ArrayMutabilityPlan.java:23)
at org.hibernate.type.descriptor.java.MutableMutabilityPlan.deepCopy(MutableMutabilityPlan.java:35)
at org.hibernate.type.descriptor.java.MutableMutabilityPlan.assemble(MutableMutabilityPlan.java:30)
at org.hibernate.type.AbstractStandardBasicType.assemble(AbstractStandardBasicType.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyPropertiesFromCache(AbstractEntityPersister.java:1153)
at org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyProperty(AbstractEntityPersister.java:994)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor$1.doWork(LazyAttributeLoadingInterceptor.java:105)
at org.hibernate.bytecode.enhance.spi.interceptor.Helper.performWork(Helper.java:97)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.loadAttribute(LazyAttributeLoadingInterceptor.java:76)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.fetchAttribute(LazyAttributeLoadingInterceptor.java:72)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.intercept(LazyAttributeLoadingInterceptor.java:61)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.readObject(LazyAttributeLoadingInterceptor.java:296)
at Classname.$$_hibernate_read_file(Classname.java)
Looking at the source code it looks like AbstractEntityPersister.java:994 will try to pull the value from the cache but there is not a check to see if the property value was initialized before the cache entry was created.