[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2716) Session.replicate failure with identity column

Max Bowsher (JIRA) noreply at atlassian.com
Thu Feb 7 08:43:33 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29470 ] 

Max Bowsher commented on HHH-2716:
----------------------------------

The javadoc for replicate says "Persist the state of the given detached instance, reusing the current identifier value.". IIUC, the specification of the identifier value is the only reason for using replicate rather than persist or save.

The current behaviour violates the documented API. It could lead to an application working entirely correctly with a pre-insert native id generator, and then developing a bug when switched to a dialect using a post-insert native id generator.

I suggest that the correct behaviour for replicate is to always try to insert the given identifier, and if the database is unable to do that, throw an exception.

> Session.replicate failure with identity column
> ----------------------------------------------
>
>                 Key: HHH-2716
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2716
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.2
>         Environment: Java 1.5, MySQL 5.0.27 and Hibernate Annotations 3.2.1.GA
>            Reporter: Yves Martin
>
> I'm trying to use replicate:
> http://www.hibernate.org/hib_docs/reference/en/html/objectstate.html#objectstate-replicating
> The column "@version" is replicated properly (same value in second db) but the column "@Id @GeneratedValue" contains a new value from the db2 sequence.
> In fact the insert statement generated by the replicate method does not include the "id" column.

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