목차

Hibernate Primary Key (ID) Generator

hibernate.id.new_generator_mappings

UUID

기본 Custom Generator들

Sequence에 대한 변화

Table Generator에 대한 변화

Identity (Auto Increment)

@Entity
public class EntityWithIdentityId {
    @Id @GeneratedValue(strategy=GenerationType.IDENTITY) Long id;
     :
}

Sequence

@Entity
// Define a sequence - might also be in another class:
@SequenceGenerator(name="seq", initialValue=1, allocationSize=100)
public class EntityWithSequenceId {
    // Use the sequence that is defined above:
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq")
    @Id Long id;
}

Table

@Entity
@TableGenerator(name="tab", initialValue=0, allocationSize=50)
public class EntityWithTableId {
    @GeneratedValue(strategy=GenerationType.TABLE, generator="tab")
    @Id Long id;
}

IdGenerator

참조