Hi all,
I am using Hibernate in my project, and many of my entities use a sequence for their technical keys. For example:
@Entity
@Table(name = "T_MYENTITY")
@SequenceGenerator(name = "S_MYENTITY", sequenceName = "S_MYENTITY")
public class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_MYENTITY")
@Column(name = "MY_ENTITY_ID")
private Long entityId;
...
}
I have two questions about the ID generated by Hibernate when a new object of this class is persisted:
- Why SequenceGenerator (from javax.persistence) has a default value of allocationSize set to 50 instead of 1? What are the interests of that?
- What is the default algorithm used by Hibernate to calculate the generated ID? It seems that Hibernate uses the value returned by the sequence hosted by my Oracle database, but then modify it before assigning it to my entity...