Search code examples
javahibernatejpa

Hibernate 6.2 strategy deprecated


The hibernate 6.2 depreciated "strategy". In our current code base we are using

@GenericGenerator(
        name = "sequenceGenerator",
        strategy = "enhanced-sequence"
    )

However, I am unsure how to replace it with the new approach.


Solution

  • the enhanced-sequence correspanding class is SequenceStyleGenerator.class So it should be replace with type = SequenceStyleGenerator.class

    @GenericGenerator(
            name = "sequenceGenerator",
            type = SequenceStyleGenerator.class
        )
    

    https://github.com/manuelbernhardt/hibernate-core/blob/7e42b464442d0535d2d1dbb7dc501c8064825d54/hibernate-core/src/main/java/org/hibernate/id/factory/DefaultIdentifierGeneratorFactory.java#L82 enter image description here