it is used hibernate_sequence instead of mySequence (with Oracle and H2)


I have updated the hiberate version from 4.0.1.Final to 5.0.7.Final (porting from Jboss 7 to Wildfly 10)

The hibernate framwork uses hibernate_sequence for the id generation instead of mySequence.

Hibernate configuration:
In order to maintain the backward compatibility, is configured as false value.

Entity configuration:
The id field is annotated with the following JPA API:

DB configuration:
The MY_GENERATOR_SEQ sequence is defined with the "INCREMENT BY 1" option.

The problem occurs for both H2 and Oracle DB.

I have analyzed the implementation and I don't know if it could be a BUG of Hibernate or any possible bad configuration i did for the backward compatibility???

Hibernate during server startup gets some initialization:
SequenceStyleGenerator.configure method defines the QualifiedName sequenceName as "hibernate_sequence", because it tried to get the value from the Properties params.
At this point I noticed that the MY_GENERATOR_SEQ sequenceName was present into the Properties params at runtime with the "sequence" key (sequence=MY_GENERATOR_SEQ) but the retrieve strategy (determineSequenceName) needs the "sequence_name" as key.
So the key used to set the sequence name into the Properties params is from the deprecated class because of,
but the SequenceStyleGenerator class needs the key in order to get "MY_GENERATOR_SEQ".

Potential solutions:
1. set on SequenceGenerator allocationSize=1 (without setting
2. create the sequence MY_GENERATOR_SEQ on the DB with INCREMENT BY 50 (without setting

Both the solutions are not applicable into my context.
So the only applicable "solution" is this one:
Extend the Dialect used for Oracle and H2 and override the getNativeIdentifierGeneratorClass method in this way:


H2 and Oracle


September 14, 2016, 4:34 AM

It seems fixed with HHH-10876

Mark Haller
May 19, 2016, 3:57 AM

I can confirm this is also happening (not surprisingly) with 5.0.6.Final

Pasquale Vitale
March 30, 2016, 7:13 AM

Unfortunately the problem is strongly related to the impossibility of update the Entity classes in my context. The suggested solution works and also the posted potential solution 1 and 2, but I can't update the Entities.

Gail Badner
March 29, 2016, 10:14 PM

An easier workaround is to use:

@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "myGenerator")




Pasquale Vitale