Since HHH-5138 and redesign of types, the type descriptor for byte[] is PrimitiveByteArrayTypeDescriptor. So when you declare an attribute of this type in an entity, Hibernate will use a BinaryType _to map it. When it comes to getting the _versionComparator, it will call this:
return PrimitiveByteArrayTypeDescriptor.INSTANCE.getComparator();
Now when you come to look to how this INSTANCE is built, the constructor AbstractTypeDescriptor(Class<T> type, MutabilityPlan<T> mutabilityPlan) is called with arguments equals to: bq: byte[].class, ArrayMutabilityPlan.INSTANCE And then comes the comparator affectation:
/**
- Initialize a type descriptor for the given type. Assumed immutable.
*
- @param type The Java type.
- @param mutabilityPlan The plan for handling mutability aspects of the java type.
*/ @SuppressWarnings(
Unknown macro: { "unchecked" }
) protected AbstractTypeDescriptor(Class<T> type, MutabilityPlan<T> mutabilityPlan)
Unknown macro: { this.type = type; this.mutabilityPlan = mutabilityPlan; this.comparator = Comparable.class.isAssignableFrom( type ) ? (Comparator<T>)ComparableComparator.INSTANCE }
Now the problem is that Comparable.class.isAssignableFrom( byte[].class) returns false, meaning that starting with Hibernate 3.6.0 and further, it becomes impossible to use a byte[] attribute as the version mapper when determining if an element can be inserted in second level cache? Or maybe I am missing something. This is quite critical for us as we are trying to migrate to more recent versions of hibernate and almost all of our version attributes are of the kind
// entity attribute private byte[] timestamp;
// hbm.xml <version type="binary" name="timestamp" generated="always" unsaved-value="undefined"> <column name="timestamp" /> </version>
|