I migrated to hibernate 6.5 and noticed deprecation of GenericGenerator, which I used to set optimizer to pooled-lo (AFAIR there is no other way to do it, but I would like to be mistaken).
Basically I have an Oracle tables with sequences as id generators with different sequence names per table (obvious) and sometimes different increment.
Example code I have now (pre 6.5):
...
private static final String SEQUENCE = "CHANGE_EVENT_SEQ";
@Id
@GenericGenerator(
name = SEQUENCE,
type = SequenceStyleGenerator.class,
parameters = {
@Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SEQUENCE),
@Parameter(name = SequenceStyleGenerator.INCREMENT_PARAM, value = "5"),
@Parameter(name = "optimizer", value = "pooled-lo")
}
)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQUENCE)
private long id;
...
Is it somehow possible to get rid of GenericGenerator and use pooled-lo optimizer?
Or should I migrate to IdGeneratorType?
IdGeneratorType is very poorly documented, all the code samples lack actual code, there are just methods names with params and there aren’t even any imports so I have no clue what packages to use for Sequence or Member (Hibernate ORM 6.0.0.CR1 User Guide):
public class CustomSequenceGenerator implements IdentifierGenerator {
public CustomSequenceGenerator(
Sequence config,
Member annotatedMember,
CustomIdGeneratorCreationContext context) {
//...
}
@Override
public Object generate(
SharedSessionContractImplementor session,
Object object) {
//...
}
How to even use that? What should I set where? It would be best if there was a guide (with code) for the section below (2.7.15) “Pooled-lo optimizer mapping using @GenericGenerator
mapping” but with IdGeneratorType.
It doesn’t help that there are very few mentions of IdGeneratorType on the web.
Could someone point me to some more detailed documentation? Or explain how I could use pooled-lo with smaller amount of code?