Actually, here your SOMETHING_SEQ is the name of the sequence that you configured somewhere in your hibernate configuration. And hibernate_sequence is the name of the sequence in the database. In the configuration, it will look something like this:
<sequence-generator name="SOMETHING_SEQ" sequence-name="hibernate_sequence" allocation-size="<any_number_value>"/>
You can skip this configuration completely by using annotation instead. Then your @SequenceGenerator annotation should provide several parameters. The following is an example.
@SequenceGenerator(name="SOMETHING_SEQ", sequenceName="hibernate_sequence", allocationSize=10)
For example, several entity classes will do something like below,
@Entity public class Entity1 { @Id @SequenceGenerator(name = "entity1Seq", sequenceName="ENTITY1_SEQ", allocationSize=1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "entity1Seq") @Column(name = "ID", nullable = false) private Long id; ... ... } @Entity public class Entity2 { @Id @SequenceGenerator(name = "entity2Seq", sequenceName="ENTITY2_SEQ", allocationSize=10) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "entity2Seq") @Column(name = "ID", nullable = false) private Long id; ... ... }
Adele ansari
source share