Bytecode enhanced lazy collection won't load from cache

Description

When loading a bytecode enhanced lazy collection of a cached entity, an exception is thrown:

Activity

Show:

Former user March 15, 2017 at 12:21 AM

Fixed in 5.1 branch as well.

Former user December 20, 2016 at 9:31 AM

, does this affect 5.1 and/or 5.0 branches as well?

Luis Barreiro December 16, 2016 at 2:31 AM

Thanks for pointing that out!

I have updated my PR to account for unfetched properties, but to avoid messing too much with the existing Type hierarchy, I've choose to do it in TypeHelper#toLoggableString() instead.
That fix was then extended to types that hold other types [ ArrayType CollectionType ComponentType ] and some other generic types as well [ AbstractStandardBasicType AnyType ]
From my inspection on the Hibernate code, that should cover all the cases!

Former user November 4, 2016 at 4:37 PM

While updating our application to Hibernate 5.2.3 we've encountered this issue with primitive property fields annotated with @Basic(fetch = FetchType.LAZY).

In a forked repo I've applied a similar fix to the one in your pull request @Luis Barreiro to the following classes

  • hibernate-core/src/main/java/org/hibernate/type/BinaryType.java

  • hibernate-core/src/main/java/org/hibernate/type/MaterializedBlobType.java

  • hibernate-core/src/main/java/org/hibernate/type/MaterializedClobType.java

  • hibernate-core/src/main/java/org/hibernate/type/MaterializedNClobType.java

A better solution may be to have a new class in the hierarchy that handles lazy property fields

BinaryType -> extends -> AbstractLazySingleColumnStandardBasicType -> extends -> AbstractSingleColumnStandardBasicType

While doing this it would be good to make the BasicType and Type interfaces generic

Luis Barreiro October 13, 2016 at 12:55 PM

Yes, I foresee an easy fix, but I want to run your test case to make sure there is not something else broken.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created October 13, 2016 at 9:42 AM
Updated March 28, 2017 at 6:33 PM
Resolved March 15, 2017 at 12:21 AM