Negative sequence with positive increment not supported with Hibernate in JBoss EAP

Solution Verified - Updated -

Issue

  • A sequence was defined using CREATE SEQUENCE EMPLOYEE_SEQ START WITH -100
  • A Hibernate entity using this sequence is defined with the following:

        @Id
        @SequenceGenerator(name = "ID_GENERATOR", sequenceName = "EMPLOYEE_SEQ", allocationSize = 1)
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ID_GENERATOR")
        private long id;
    
  • When an instance of the entity is created, the assigned id value is 0 rather than the next sequence value (if the next sequence value is < 0).

Environment

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

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