[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6486) Negative ID created using Sequences

Andreas Beckers (JIRA) noreply at atlassian.com
Mon Aug 1 17:17:02 EDT 2011


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

Andreas Beckers commented on HHH-6486:
--------------------------------------

@Sebastian: I had allocationSize=default=50, but the sequence had an increment of 1. The generator took the next value from the sequence, e.g. 10. The generator thought it could use the range from -40 to 10. So the next id was negative.
The increment of the sequence and the allocationSize must be set to the same value.

> Negative ID created using Sequences
> -----------------------------------
>
>                 Key: HHH-6486
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6486
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.0.0.Beta1, 4.0.0.Beta4
>         Environment: JBoss 7.0.0.Final with Hibernate 4.0.0.Beta4, Oracle 10 Express
>            Reporter: Andreas Beckers
>
> We use seperated sequences for each table. Our IDs are annotated like this:
>     @SequenceGenerator(name = "PersonGen", sequenceName = "person_id_seq")
>     @Id
>     @GeneratedValue(generator = "PersonGen")
>     public long getId() {
>         return _id;
>     }
> The sequence is defined like this:
> CREATE SEQUENCE person_id_seq START WITH 1 INCREMENT BY 1 NOCACHE;
> The Problem is, that I get negative IDs in my object and the generated IDs are not unique. I get the error
> java.sql.SQLIntegrityConstraintViolationException: ORA-00001: Unique Constraint (VESUVZPONF.PERSON_PKEY) verletzt
> In the log I see:
> Generated identifier: -21, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
> The code worked in JBoss 6.0.0.Final using Hibernate 3.6.0.Final
> I tried auto strategy which uses a single sequence that works fine.
> There are ManyToOne and OneToMany relations with cascade all, don't know if that's of importance.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list