<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://kwonnam.pe.kr/wiki/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://kwonnam.pe.kr/wiki/feed.php">
        <title>권남 java:hibernate:usertype</title>
        <description></description>
        <link>https://kwonnam.pe.kr/wiki/</link>
        <image rdf:resource="https://kwonnam.pe.kr/wiki/lib/tpl/dokuwiki/images/favicon.ico" />
       <dc:date>2026-04-06T19:37:09+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://kwonnam.pe.kr/wiki/java/hibernate/usertype/generic_enum?rev=1416449703&amp;do=diff"/>
                <rdf:li rdf:resource="https://kwonnam.pe.kr/wiki/java/hibernate/usertype/stringboolean?rev=1597207221&amp;do=diff"/>
                <rdf:li rdf:resource="https://kwonnam.pe.kr/wiki/java/hibernate/usertype/stringdate?rev=1416449971&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://kwonnam.pe.kr/wiki/lib/tpl/dokuwiki/images/favicon.ico">
        <title>권남</title>
        <link>https://kwonnam.pe.kr/wiki/</link>
        <url>https://kwonnam.pe.kr/wiki/lib/tpl/dokuwiki/images/favicon.ico</url>
    </image>
    <item rdf:about="https://kwonnam.pe.kr/wiki/java/hibernate/usertype/generic_enum?rev=1416449703&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2014-11-20T11:15:03+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>java:hibernate:usertype:generic_enum</title>
        <link>https://kwonnam.pe.kr/wiki/java/hibernate/usertype/generic_enum?rev=1416449703&amp;do=diff</link>
        <description>Hibernate Generic Enum UserType

	*  Enum의 값을 단순 name()이 아닌 다른 값으로 자유롭게 매핑하고 싶을 때 사용하는 Hibernate User Type.
	*  Java 5 EnumUserType
	*  java.lang.verifyError on hibernate specific usertype for Hibernate 4 - Stack Overflow
	*  위 두 링크에 있는 UserType을 Hibernate 4 용으로 변환한 것. Hibernate User Type 참조.


public class GenericEnumUserType implements UserType, ParameterizedType {

	/** 대상 enum 클래스를 문자열로 지정한다 */
	public static final String PARAM_ENUM_CLASS = &quot;enumClass&quot;;

	/** Enum을 실제 저장할 문자열로 바꿔주는 메소드. 이 메소…</description>
    </item>
    <item rdf:about="https://kwonnam.pe.kr/wiki/java/hibernate/usertype/stringboolean?rev=1597207221&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-08-12T13:40:21+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>java:hibernate:usertype:stringboolean</title>
        <link>https://kwonnam.pe.kr/wiki/java/hibernate/usertype/stringboolean?rev=1597207221&amp;do=diff</link>
        <description>StringBoolean Hibernate UserType

boolean을 DB상에서는 문자열로 매핑하는 Hibernate User Type.
Hibernate는 기본적으로 “yes_no”와 “true_false”라는 문자열 Boolean 매핑이 이미 존재한다. 하지만 이들는 “Y/N”, “T/F” 이외의 알 수 없는 값이 들어왔을 때 오류를 발생시킨다.</description>
    </item>
    <item rdf:about="https://kwonnam.pe.kr/wiki/java/hibernate/usertype/stringdate?rev=1416449971&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2014-11-20T11:19:31+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>java:hibernate:usertype:stringdate</title>
        <link>https://kwonnam.pe.kr/wiki/java/hibernate/usertype/stringdate?rev=1416449971&amp;do=diff</link>
        <description>StringDate Hibernate UserType

Database에 날짜를 문자열로 저장했을 경우 사용하는 Hibernate User Type.

java.util.Date 객체를 문자열로 변환해서 저장하고, 읽을 때 문자열에서 다시 Date 객체로 변환한다.

코드


public class StringDateUserType implements UserType, ParameterizedType {

  public static final String PARAM_FORMAT = &quot;format&quot;;
  public static final String DEFAULT_FORMAT = &quot;yyyyMMddHHmmss&quot;;

  private AbstractSingleColumnStandardBasicType type;
  private int[] sqlTypes = null;
  private String format;

  @Override
  public void setParameterV…</description>
    </item>
</rdf:RDF>
