Why would an entity's sequence based ID differ from the database current sequence value in EAP 6?

Solution Verified - Updated -

Issue

  • An entity class identifier is declared as follows

        ...
        @Id
        @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="EVENT_SEQ_GEN")
        @SequenceGenerator(name="EVENT_SEQ_GEN", sequenceName="EVENT_SEQ")
        ...
    
    • At the time an instance of the entity class is created, the value of an Oracle sequence (EVENT_SEQ) in the database is 55
    • During insert of the instance, the ID value automatically populated is different from the sequence value (e.g. 51 or 2753)
  • How does the SEQUENCE generation strategy work?
  • What is the impact of the hibernate.id.new_generator_mappings property?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 6
  • Hibernate 4
  • Oracle

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content