We have .hbm.xml mappings that use sequence generators like that:
<id name="rowguid" type="java.lang.Long">
<generator class="sequence">
<param name="sequence_name">scm_t_key_value_store_rowguid_seq</param>
</generator>
</id>
After updating from Hibernate 5.6 to 6.1, we get the following message for each of our mapped entities:
Caused by: org.hibernate.MappingException: The increment size of the [scm_t_key_value_store_rowguid_seq] sequence is set to [50] in the entity mapping while the associated database sequence increment size is [1].
at deployment.tg-myapp.war//org.hibernate.id.enhanced.SequenceStyleGenerator.configure(SequenceStyleGenerator.java:218)
at deployment.tg-myapp.war//org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory.createIdentifierGenerator(StandardIdentifierGeneratorFactory.java:217)
… 53 more
After reading about some solutions, I have created an orm.xml to define a new sequence with a allocation-size of 1:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0">
<sequence-generator name="global_seq_gen" allocation-size="1" />
</entity-mappings>
And I apply this generator like this:
<id name="rowguid" column="rowguid" type="java.lang.Long">
<generator class="sequence">
<param name="sequence_name">global_seq_gen</param>
</generator>
</id>
My question: Is that sufficient to have each table increase the id by 1 without interference between different tables?