문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
java:hibernate:id_generator [2018/07/11 14:11] kwon37xi |
java:hibernate:id_generator [2018/07/11 14:17] kwon37xi [IdGenerator] |
||
---|---|---|---|
줄 18: | 줄 18: | ||
* 기존방식 : [[https:// | * 기존방식 : [[https:// | ||
* 새 방식 : [[https:// | * 새 방식 : [[https:// | ||
+ | |||
+ | ===== Identity (Auto Increment) ===== | ||
+ | <code java> | ||
+ | @Entity | ||
+ | public class EntityWithIdentityId { | ||
+ | @Id @GeneratedValue(strategy=GenerationType.IDENTITY) Long id; | ||
+ | : | ||
+ | } | ||
+ | </ | ||
===== Sequence ===== | ===== Sequence ===== | ||
줄 27: | 줄 36: | ||
// 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: | 줄 46: | ||
public class EntityWithTableId { | public class EntityWithTableId { | ||
@GeneratedValue(strategy=GenerationType.TABLE, | @GeneratedValue(strategy=GenerationType.TABLE, | ||
- | @Id long id; | + | @Id Long id; |
} | } | ||
</ | </ | ||
줄 87: | 줄 96: | ||
} | } | ||
</ | </ | ||
- | * [[https:// | + | * '' |