-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: WrappedMaterializedBlobType - wrong dirty checking
PostPosted: Tue Nov 13, 2012 10:41 am 
Newbie

Joined: Tue Nov 13, 2012 10:19 am
Posts: 5
Hello,

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" />


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   


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() {}

}


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)


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 );
      }
   }


Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.