[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4110) Dirty check fail for CharArrayType

Maillefer Jean-David (JIRA) noreply at atlassian.com
Fri Aug 28 04:45:18 EDT 2009


Dirty check fail for CharArrayType
----------------------------------

                 Key: HHH-4110
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4110
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.3.2
            Reporter: Maillefer Jean-David


Entity fields of type char[] are mapped using class org.hibernate.typeAbstractCharArrayType.
These fields are always marked dirty by the dirty check mechanism and thus are always updated to the database.

The dirty check implementation uses inherited org.hibernate.type.NullableType#isEqual(Object, Object) which in turn call org.hibernate.util.EqualsHelper.equals(Object, Object) which does only a reference check for array, not a "deep" check similar to Arrays.equals(char[], char[]).

I suggest overriding #isEqual(Object, Object) in AbstractCharArrayType with the following code (adapted from EqualsHelper) :
  public boolean isEqual(Object x, Object y) {
      return x==y || ( x instanceof char[] && y instanceof char[] && Arrays.equals((char[])x, (char[])y) );
  }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list