문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
java:hibernate:id_generator [2018/07/11 14:11] kwon37xi |
java:hibernate:id_generator [2018/08/22 08:52] kwon37xi [Hibernate Primary Key (ID) Generator] |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== Hibernate Primary Key (ID) Generator ====== | ====== Hibernate Primary Key (ID) Generator ====== | ||
+ | * [[https:// | ||
* [[https:// | * [[https:// | ||
줄 18: | 줄 19: | ||
* 기존방식 : [[https:// | * 기존방식 : [[https:// | ||
* 새 방식 : [[https:// | * 새 방식 : [[https:// | ||
+ | |||
+ | ===== Identity (Auto Increment) ===== | ||
+ | <code java> | ||
+ | @Entity | ||
+ | public class EntityWithIdentityId { | ||
+ | @Id @GeneratedValue(strategy=GenerationType.IDENTITY) Long id; | ||
+ | : | ||
+ | } | ||
+ | </ | ||
===== Sequence ===== | ===== Sequence ===== | ||
줄 27: | 줄 37: | ||
// Use the sequence that is defined above: | // Use the sequence that is defined above: | ||
@GeneratedValue(strategy=GenerationType.SEQUENCE, | @GeneratedValue(strategy=GenerationType.SEQUENCE, | ||
- | @Id long id; | + | @Id Long id; |
} | } | ||
</ | </ | ||
줄 37: | 줄 47: | ||
public class EntityWithTableId { | public class EntityWithTableId { | ||
@GeneratedValue(strategy=GenerationType.TABLE, | @GeneratedValue(strategy=GenerationType.TABLE, | ||
- | @Id long id; | + | @Id Long id; |
} | } | ||
</ | </ | ||
줄 87: | 줄 97: | ||
} | } | ||
</ | </ | ||
- | * [[https:// | + | * '' |