I'm migrating an application to Hibernate 4. One of the classes has a property mapped with the type WrappedMaterializedBlobType.
<code>
private Byte[] jks;
<property access="field" column="JKS" generated="never" lazy="false" name="jks" type="org.hibernate.type.WrappedMaterializedBlobType" />
</code>
I have debugged the code and I think there is a bug in the dirty checking.
This is the stack trace:
<code>
EqualsHelper.equals(Object, Object) line: 34
ByteArrayTypeDescriptor(AbstractTypeDescriptor<T>).areEqual(T, T) line: 95
WrappedMaterializedBlobType(AbstractStandardBasicType<T>).isEqual(Object, Object) line: 196
WrappedMaterializedBlobType(AbstractStandardBasicType<T>).isSame(Object, Object) line: 186
WrappedMaterializedBlobType(AbstractStandardBasicType<T>).isDirty(Object, Object) line: 222
WrappedMaterializedBlobType(AbstractStandardBasicType<T>).isDirty(Object, Object, boolean[], SessionImplementor) line: 218
TypeHelper.findDirty(StandardProperty[], Object[], Object[], boolean[][], boolean, SessionImplementor) line: 294
JoinedSubclassEntityPersister(AbstractEntityPersister).findDirty(Object[], Object[], Object, SessionImplementor) line: 3829
DefaultFlushEntityEventListener.dirtyCheck(FlushEntityEvent) line: 527
DefaultFlushEntityEventListener.isUpdateNecessary(FlushEntityEvent, boolean) line: 234
DefaultFlushEntityEventListener.onFlushEntity(FlushEntityEvent) line: 163
</code>
And the comparasion between the old and the current version of the Byte[] is done in this way:
<code>
public final class EqualsHelper {
public static boolean equals(final Object x, final Object y) {
return x == y || ( x != null && y != null && x.equals( y ) );
}
private EqualsHelper() {}
}
</code>
If really it's a bug, I think the class ByteArrayTypeDescriptor should overwrite the method areEqual, and have something like:
<code>
Arrays.deepEquals(oldVersionEntity, currentVersionEntity)
</code>
or like in the deprecated class ByteArrayBlobType:
<code>
public boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) {
if ( x == y ) return true;
if ( x == null || y == null ) return false;
if ( x instanceof Byte[] ) {
Object[] o1 = (Object[]) x;
Object[] o2 = (Object[]) y;
return ArrayHelper.isEquals( o1, o2 );
}
else {
byte[] c1 = (byte[]) x;
byte[] c2 = (byte[]) y;
return ArrayHelper.isEquals( c1, c2 );
}
}
</code>
|