1 package com.vladmihalcea.hibernate.type.basic;
2
3 import com.vladmihalcea.hibernate.type.AbstractHibernateType;
4 import com.vladmihalcea.hibernate.type.basic.internal.YearMonthTypeDescriptor;
5 import com.vladmihalcea.hibernate.type.util.Configuration;
6 import org.hibernate.type.descriptor.sql.DateTypeDescriptor;
7
8 import java.time.YearMonth;
9
10 /**
11  * Maps a Java {@link java.time.YearMonth} object to a {@code DATE} column type.
12  * <p>
13  * For more details about how to use it, check out <a href="https://vladmihalcea.com/java-yearmonth-jpa-hibernate/">this article</a> on <a href="https://vladmihalcea.com/">vladmihalcea.com</a>.
14  *
15  * @author Vlad Mihalcea
16  */

17 public class YearMonthDateType
18         extends AbstractHibernateType<YearMonth> {
19
20     public static final YearMonthDateType INSTANCE = new YearMonthDateType();
21
22     public YearMonthDateType() {
23         super(
24             DateTypeDescriptor.INSTANCE,
25             YearMonthTypeDescriptor.INSTANCE
26         );
27     }
28
29     public YearMonthDateType(Configuration configuration) {
30         super(
31             DateTypeDescriptor.INSTANCE,
32             YearMonthTypeDescriptor.INSTANCE,
33             configuration
34         );
35     }
36
37     public String getName() {
38         return "yearmonth-date";
39     }
40
41     @Override
42     protected boolean registerUnderJavaType() {
43         return true;
44     }
45 }