[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2680) Blobs not updated on Session.merge() for detached instances

Steve Ebersole (JIRA) noreply at atlassian.com
Fri Jun 11 13:34:59 EDT 2010


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

Steve Ebersole commented on HHH-2680:
-------------------------------------

Part of the problem is that this is database specific.  A consensus seems to be that this fails on Oracle.  Oracle is very particular in that only LOBs associated with the Connection are used.  So if you try to use a Blob, for example, that was pulled from a previous Connection and bind it into the current Connection nothing happens; it is simply ignored.  But not all databases are this "particular".  And the problem is that the JDBC spec does nothing to clarify what should happen here.  But it does give guidance that the Oracle "particularity" should be followed for "maximum portability".

At any rate, even for Oracle, isn't the more correct solution to copy the Blob state to the just read Blob?  The suggestions here are saying to create a whole new BLOB, but isn't the "correct" thing to do on Oracle:
{code}
public Object replace(
        Object original, 
        Object target,
        SessionImplementor session, 
        Object owner, 
        Map copyCache) throws HibernateException {
    if ( original != target ) {
        OutputStream connectedStream = ( (Blob) target ).setBinaryStream( 1L );  // the BLOB just read during the load phase of merge
        InputStream detachedStream = ( (Blob) original ).getBinaryStream();      // the BLOB from the detached state
        copy( detachedStream, connectedStream );  // from, into
    }
    return target;
}
{code}
?


> Blobs not updated on Session.merge() for detached instances
> -----------------------------------------------------------
>
>                 Key: HHH-2680
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2680
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.2, 3.2.4.sp1
>         Environment: Windows XP Prof., Java 1.5_010, HSQLDB 1.8.0
>            Reporter: Timo Thomas
>         Attachments: blobmerge.patch, BlobTest.zip, FileBlob.java, FixedBlobType.java
>
>
> Blob columns are not updated when a detached instance is saved at the session with merge(). See attached TestCase.

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