사용자 도구

사이트 도구


java:hibernate:id_generator

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
java:hibernate:id_generator [2018/07/11 14:12]
kwon37xi [Table]
java:hibernate:id_generator [2018/11/09 14:06]
kwon37xi
줄 1: 줄 1:
 ====== Hibernate Primary Key (ID) Generator ====== ====== Hibernate Primary Key (ID) Generator ======
 +  * [[https://www.thoughts-on-java.org/custom-sequence-based-idgenerator/|How to Implement a Custom, Sequence-Based IdGenerator]]
   * [[https://www.objectdb.com/java/jpa/entity/generated|JPA Generated Values (@GeneratedValue, @SequenceGenerator, @TableGenerator)]]   * [[https://www.objectdb.com/java/jpa/entity/generated|JPA Generated Values (@GeneratedValue, @SequenceGenerator, @TableGenerator)]]
  
 ===== hibernate.id.new_generator_mappings ===== ===== hibernate.id.new_generator_mappings =====
-  * 최신버전에서는 ''hibernate.id.new_generator_mappings=true'' 프라퍼티를 통해 새로운 방식으로 ID를 생성할 수 있다. 특히 Sequence에 해당하는 방식인듯.+  * 최신버전에서는 ''hibernate.id.new_generator_mappings=true'' 프라퍼티를 통해 JPA에 호환성에 부합하는 새로운 방식으로 ID를 생성할 수 있다. 보통은 이 값이 true이면 sequence 시도 안되면 table 시도로 선택한다. 
 +  * 구버전과의 호환성을 위한 것이 아니면 이 값을 **항상 ''true''**로 주고, MySQL 등 AUTO INCREMENT 계열는 ID 생성 방식을 ''AUTO''보다는 **구체적으로 IDENTITY로 명시**하도록 하자.
   * [[http://in.relation.to/2082.lace|In Relation To...  New (3.2.3) Hibernate identifier generators]]   * [[http://in.relation.to/2082.lace|In Relation To...  New (3.2.3) Hibernate identifier generators]]
   * [[http://java.dzone.com/articles/jpa-hibernates-legacy-and|From JPA to Hibernate's Legacy and Enhanced Identifier Generators]]   * [[http://java.dzone.com/articles/jpa-hibernates-legacy-and|From JPA to Hibernate's Legacy and Enhanced Identifier Generators]]
 +  * [[https://www.popit.kr/%ED%95%98%EC%9D%B4%EB%B2%84%EB%84%A4%EC%9D%B4%ED%8A%B8%EB%8A%94-%EC%96%B4%EB%96%BB%EA%B2%8C-%EC%9E%90%EB%8F%99-%ED%82%A4-%EC%83%9D%EC%84%B1-%EC%A0%84%EB%9E%B5%EC%9D%84-%EA%B2%B0%EC%A0%95%ED%95%98/|하이버네이트는 어떻게 자동 키 생성 전략을 결정하는가 | Popit]]
 +
 +===== UUID =====
 +  * [[https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html|UUID]] ID 는 기본적으로 **Binary**로 매핑된다. 
 +  * 또한 ID Generator는 [https://docs.jboss.org/hibernate/orm/5.0/javadocs/org/hibernate/id/UUIDGenerator.html|UUIDGenerater]]를 사용한다.
 +  * 해당 컬럼을 문자열로 지정하고 싶다면 ''@Type(type="uuid-char")''를 붙인다.
  
 ===== 기본 Custom Generator들 ===== ===== 기본 Custom Generator들 =====
줄 53: 줄 61:
 ===== IdGenerator ===== ===== IdGenerator =====
   * ID 생성기를 Custom으로 만들 수 있다.   * ID 생성기를 Custom으로 만들 수 있다.
 +  * [[https://vladmihalcea.com/how-to-implement-a-custom-string-based-sequence-identifier-generator-with-hibernate/|How to implement a custom String-based sequence identifier generator with Hibernate - Vlad Mihalcea]]
   * [[http://blog.anorakgirl.co.uk/2009/01/custom-hibernate-sequence-generator-for-id-field/|Custom Hibernate Sequence Generator for Id field]]   * [[http://blog.anorakgirl.co.uk/2009/01/custom-hibernate-sequence-generator-for-id-field/|Custom Hibernate Sequence Generator for Id field]]
   * [[http://stackoverflow.com/questions/11631800/hibernate-how-specify-custom-sequence-generator-class-name-using-annotations|jpa - Hibernate: How specify custom sequence generator class name using annotations?]]   * [[http://stackoverflow.com/questions/11631800/hibernate-how-specify-custom-sequence-generator-class-name-using-annotations|jpa - Hibernate: How specify custom sequence generator class name using annotations?]]
줄 96: 줄 105:
 } }
 </code> </code>
-  * [[https://docs.jboss.org/hibernate/orm/4.3/javadocs/org/hibernate/annotations/GenericGenerator.html|@GenericGenerator]]에 파라미터를 지정하는 것도 가능하다. 이를 자신이 만든 Generator에서 받아서 사용한다.+  * ''org.hibernate.id.Configurable'' 인터페이스를 함께 구현하여 [[https://docs.jboss.org/hibernate/orm/4.3/javadocs/org/hibernate/annotations/GenericGenerator.html|@GenericGenerator]]에 파라미터를 지정하는 것도 가능하다. 이를 자신이 만든 Generator에서 받아서 사용한다.
  
java/hibernate/id_generator.txt · 마지막으로 수정됨: 2023/06/09 10:02 저자 kwon37xi