0

I have a java spring boot project which needs to be run on both MySQL and Oracle databases. The project has multiple entities with primary keys set to auto-increment in the db.

I have identified that Hibernate's @GenericGenerator in native strategy will support both MySQL (as IDENTITY) and Oracle (as SEQUENCE) in terms of auto-increment depending on the type of db. But I can't seem to find how to set the allocationSize in the GenericGenerator, for an oracle sequence. I want the allocationSize to be set to 1.

@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator="gen")
@GenericGenerator(name = "gen", strategy = "native")
@Column(name = "id", nullable = false)
private Long id;

//Getter and Setter

1 Answers1

0

@GenericGenerator is a hibernate annotation used to denote a custom generator, which can be a class or shortcut to a generator supplied by Hibernate. increment is a shortcut to a Hibernate generator.

check this link below: - Hibernate, @SequenceGenerator and allocationSize