sequenceName
is the name of the sequence in the DB. This is how you specify a sequence that already exists in the DB. If you go this route, you have to specify the allocationSize
which needs to be the same value that the DB sequence uses as its "auto increment".
Usage:
@GeneratedValue(generator="my_seq")
@SequenceGenerator(name="my_seq",sequenceName="MY_SEQ", allocationSize=1)
If you want, you can let it create a sequence for you. But to do this, you must use SchemaGeneration to have it created. To do this, use:
@GeneratedValue(strategy=GenerationType.SEQUENCE)
Also, you can use the auto-generation, which will use a table to generate the IDs. You must also use SchemaGeneration at some point when using this feature, so the generator table can be created. To do this, use:
@GeneratedValue(strategy=GenerationType.AUTO)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…