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

Andreas Beckers (JIRA) noreply at atlassian.com
Tue Jul 26 10:17:15 EDT 2011


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.Beta4, 4.0.0.Beta1
         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