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:
bq. 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: { quote code:java } /** * 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({ "unchecked" }) protected AbstractTypeDescriptor(Class<T> type, MutabilityPlan<T> mutabilityPlan) { this.type = type; this.mutabilityPlan = mutabilityPlan; this.comparator = Comparable.class.isAssignableFrom( type ) ? (Comparator<T>)ComparableComparator.INSTANCE : null; } { quote code }
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 {quote} // entity attribute private byte[] timestamp;
// hbm.xml <version type="binary" name="timestamp" generated="always" unsaved-value="undefined"> <column name="timestamp" /> </version> {quote} |
|