I have some code:
@Id
@SequenceGenerator(name = "SOMETHING_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SOMETHING_SEQ")
@Column(name = "SOMETHING", nullable = false)
private Long id;
How is hibernate providing my id?
I see in my database there a single sequence named ‘hibernate_sequence’ and no other hibernate ‘special tables’.
Actually, here your
SOMETHING_SEQis the name of sequence you configured somewhere in your hibernate config. Andhibernate_sequenceis the sequence name in the database. In configuration it would be looking something like below,You can completely skip this configuration by using annotation instead. Then your
@SequenceGeneratorannotation would need to provide few more paramters. Below is the example.For example multiple entity classes would do something like below,