사용자 도구

사이트 도구


java:hibernate:usertype

차이

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

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
java:hibernate:usertype [2016/09/18 17:18]
kwon37xi [Hibernate User Type]
java:hibernate:usertype [2018/10/24 10:26] (현재)
kwon37xi
줄 1: 줄 1:
 ====== Hibernate User Type ====== ====== Hibernate User Type ======
   * ''UserType'', ''ParameterizedType'' 을 통해 사용자 정의 타입을 만들 수 있다.   * ''UserType'', ''ParameterizedType'' 을 통해 사용자 정의 타입을 만들 수 있다.
 +  * [[https://github.com/vladmihalcea/hibernate-types|vladmihalcea/hibernate-types: The Hibernate Types repository gives you extra types that are not supported by the Hibernate ORM core.]]
   * [[java:hibernate:usertype:generic_enum|Hibernate Generic Enum UserType]]   * [[java:hibernate:usertype:generic_enum|Hibernate Generic Enum UserType]]
   * [[java:hibernate:usertype:stringdate|StringDate Hibernate UserType]]   * [[java:hibernate:usertype:stringdate|StringDate Hibernate UserType]]
줄 6: 줄 7:
   * UserType의 ''nullSafeSet''과 ''nullSafeGet''에서 값에 대한 로그를 ''trace'' 레벨로 남겨주어 쿼리 결과나 쿼리를 날릴 때의 로그로 해당 값을 Hibernate가 자동으로 남겨주는 다른 값들과 함께 로그로 남긴다.   * UserType의 ''nullSafeSet''과 ''nullSafeGet''에서 값에 대한 로그를 ''trace'' 레벨로 남겨주어 쿼리 결과나 쿼리를 날릴 때의 로그로 해당 값을 Hibernate가 자동으로 남겨주는 다른 값들과 함께 로그로 남긴다.
   * **''nullSafeGet''/''nullSafeSet''은 ''org.hibernate.type.StandardBasicTypes''의 실제 Type 상수에게 위임해주는 것이 좋다.**   * **''nullSafeGet''/''nullSafeSet''은 ''org.hibernate.type.StandardBasicTypes''의 실제 Type 상수에게 위임해주는 것이 좋다.**
-    * 이 경우 굳이 UserType의 ''nullSafeGet/nullSafeSet''에서 로그를 안남겨도 알아서 남는다.+    * 이 경우 굳이 UserType의 ''nullSafeGet/nullSafeSet''에서 로그를 안 남겨도 알아서 남는다.
   * [[https://github.com/jamesward/spring_hibernate_hstore_demo|Hibernate PostgresQL HStore]]   * [[https://github.com/jamesward/spring_hibernate_hstore_demo|Hibernate PostgresQL HStore]]
  
줄 41: 줄 42:
  
 </code> </code>
 +
 ===== Primary Key ===== ===== Primary Key =====
   * Primary Key(Identifier)나  Descriminator(상속관계에서 구분자?)로 사용할 Custom Type은 ''org.hibernate.usertype.EnhancedUserType''를 구현해야 한다.   * Primary Key(Identifier)나  Descriminator(상속관계에서 구분자?)로 사용할 Custom Type은 ''org.hibernate.usertype.EnhancedUserType''를 구현해야 한다.
 +
 +===== java.time.Year, java.time.Month =====
 +  * [[https://vladmihalcea.com/java-time-year-month-jpa-hibernate/|How to map java.time.Year and java.time.Month with JPA and Hibernate - Vlad Mihalcea]]
 +  * 기본적으로는 JPA ''AttributeConverter''를 사용한다.
 +  * Hibernate 사용시에는 ''AbstractSingleColumnStandardBasicType''와 ''AbstractTypeDescriptor''로 처리 가능하다. 이에 관한 예제.
 +
 +===== 참고 =====
 +  * [[https://www.baeldung.com/hibernate-custom-types|Custom Types in Hibernate | Baeldung]]
  
java/hibernate/usertype.1474188504.txt.gz · 마지막으로 수정됨: 2016/09/18 17:18 저자 kwon37xi