Hibernate 6 Migration - Id Generation

have a base entity. I have a sequence per entity strategy. Increment size is 100. As per documentation in hibernate 6, default strategy is sequence per entity. But i couldn’t find a way to set default increment size to 100.

How i can migrate the code below to work with hibernate 6.


@Getter
@Setter
@MappedSuperclass
@Audited
public abstract class AbstractEntity {

    @Id
    @GeneratedValue(generator = "optimized-sequence")
    @GenericGenerator(
        name = "optimized-sequence",
        strategy = "enhanced-sequence",
        parameters = {
            @Parameter(name = SequenceStyleGenerator.CONFIG_PREFER_SEQUENCE_PER_ENTITY, value = "true"),
            @Parameter(name = SequenceStyleGenerator.INCREMENT_PARAM, value = "100")})
    private Long id;

I don’t think there is a way to configure a global default increment size yet. Try replacing the @GenericGenerator with @SequenceGenerator(name = "optimized-sequence", allocationSize = 100). If that doesn’t work, you can create a feature request for this if you want. In the meantime, you will have to define every sequence generator on the respective entity types by annotating e.g. @SequenceGenerator(name = "optimized-sequence", sequenceName = "abc_seq", allocationSize = 100)

It doesn’t work.

Since it is our base entity, i don’t want to move it from base to every entity. We have a lot of entities.

Then there is no other way right now. Please create a JIRA issue for the feature request.