[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-5053) Duplicate primary keys when using the SEQUENCE strategy due to underlying sequence not being updated when the SequenceGenerator's allocatedSize is greater than 1

Steve Ebersole (JIRA) noreply at atlassian.com
Tue May 11 11:45:24 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole updated HHH-5053:
--------------------------------

    Assignee: Steve Ebersole  (was: Gail Badner)

> Duplicate primary keys when using the SEQUENCE strategy due to underlying sequence not being updated when the SequenceGenerator's allocatedSize is greater than 1
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-5053
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5053
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.0-CR-2, 3.5.1
>         Environment: Hibernate 3.5.0-CR-2
> PostgreSQL 8.4.1 (JDBC driver 8.4-701 JDBC4)
> Glassfish v3 (build 74.2)
> JDK 1.6.0_18
>            Reporter: atomicknight
>            Assignee: Steve Ebersole
>         Attachments: Hibernate351BugTest.java, jpa-test.war, table1.sql
>
>
> When the SequenceGenerator's allocatedSize is greater than 1, the underlying sequence associated with the table doesn't ever seem to be updated by Hibernate except on application startup. The test case uses an allocatedSize of 3, corresponding to an increment value of 3 in the underlying sequence.
> Here's how to use the test case (requires EJB 3.1):
> 1) Set up the database using the attached SQL dump, then load the application
> 2) Access the test page via http://localhost:8080/jpa-test/test. You should see a page with the word "Done!"
> 3) Undeploy and redeploy the application
> 4) Access the test page again. You should encounter an error page indicating that the transaction was aborted.
> Here's what I observed at the database level while following the above steps:
> 1) Sequence is created with a start value of 1 and increment value of 3.
> 2) Hibernate increments the sequence to 4. The application then inserts rows with IDs 12-31.
> 3) No change - the sequence still has a value of 4.
> 4) Hibernate increments the sequence to 7. The application attempts to insert a row with ID 21, but fails because the ID was already used in step 2.
> Setting the SequenceGenerator's allocatedSize to 1 as well as changing the increment value of the sequence to 1 gives the correct behavior.

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