[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (HHH-5811) flush causes update query on field of type Byte[]

K C (JIRA) noreply at atlassian.com
Mon Jan 3 06:01:05 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39463#action_39463 ] 

K C edited comment on HHH-5811 at 1/3/11 4:59 AM:
--------------------------------------------------

When executing 'mvn test', 3 out of the 4 tests should succeed, one fails. The only differenece being the type of the field: Byte[] fails, byte[], Character[] and char[] work.

With Byte[], Hibernate issues an additional update, as can be seen in stdout:
Hibernate: select testentity0_.id as id0_0_, testentity0_.nativeByteArray as nativeBy2_0_0_, testentity0_.nativeByteWrapperArray as nativeBy3_0_0_, testentity0_.nativeCharArray as nativeCh4_0_0_, testentity0_.nativeCharWrapperArray as nativeCh5_0_0_, testentity0_.version as version0_0_ from TestEntity testentity0_ where testentity0_.id=?
Hibernate: update TestEntity set nativeByteArray=?, nativeByteWrapperArray=?, nativeCharArray=?, nativeCharWrapperArray=?, version=? where id=? and version=?

For the sample, the db is an in memory HsqlDb (normally we run on Oracle)

      was (Author: kccoyote):
    Added sample.

When executing 'mvn test', 3 out of the 4 tests should succeed, one fails. The only differenece being the type of the field: Byte[] fails, byte[], Character[] and char[] work.

With Byte[], Hibernate issues an additional update, as can be seen in stdout:
Hibernate: select testentity0_.id as id0_0_, testentity0_.nativeByteArray as nativeBy2_0_0_, testentity0_.nativeByteWrapperArray as nativeBy3_0_0_, testentity0_.nativeCharArray as nativeCh4_0_0_, testentity0_.nativeCharWrapperArray as nativeCh5_0_0_, testentity0_.version as version0_0_ from TestEntity testentity0_ where testentity0_.id=?
Hibernate: update TestEntity set nativeByteArray=?, nativeByteWrapperArray=?, nativeCharArray=?, nativeCharWrapperArray=?, version=? where id=? and version=?

For the sample, the db is an in memory HsqlDb (normally we run on Oracle)
  
> flush causes update query on field of type Byte[]
> -------------------------------------------------
>
>                 Key: HHH-5811
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5811
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: entity-manager
>    Affects Versions: 3.6.0
>         Environment: Hibernate 3.6.0.Final, Oracle 11g
>            Reporter: K C
>         Attachments: hhh-5811.zip
>
>
> I have a field that is mapped as follows:
>     @Lob
>     @Column(name = "picture")
>     private Byte[] picture;
> When retrieving the entity with a regular session.load() or criteria.list(), upon session flush, an update statement is issued for the field. 
> In an interceptor, I can see in the onFlushDirty method that the byte arrays in the currentState en previousState parameters are different objects, but with the same byte-content. All the other objects in currentState and previousState are identical.
> My guess is that this causes Hibernate to think the contents of the field changed?
> This behavior did not happen in 3.5.5-Final, and because the entity is versioned, upon each retrieval, the version field is incremented, which is highly undesirable.

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