Since 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:
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:
And then comes the comparator affectation:
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;
<version type="binary" name="timestamp" generated="always" unsaved-value="undefined">
<column name="timestamp" />
Hibernate 3.6.0 and further
This will be fixed by HHH-8999.
Reopening as this issue will not be fixed by
I've added a new type, org.hibernate.type.RowVersionType, that will automatically be used for byte versions/timestamps. RowVersionType implements VersionType.
This fix includes deprecation of VersionType method implementations in org.hibernate.type.BinaryType, since BinaryType will no longer be used for byte versions/timestamps.
VersionType implementation of BinaryType will be removed by HHH-10902.
Fixed in master, 5.1, and 5.0 branches.
Thanks for your efforts in fixing the problem