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.IntegerTypeDescriptor;
7
8 import java.time.YearMonth;
9
10 /**
11  * Maps a Java {@link YearMonth} object to an {@code INT} 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 YearMonthIntegerType
18         extends AbstractHibernateType<YearMonth> {
19
20     public static final YearMonthIntegerType INSTANCE = new YearMonthIntegerType();
21
22     public YearMonthIntegerType() {
23         super(
24             IntegerTypeDescriptor.INSTANCE,
25             YearMonthTypeDescriptor.INSTANCE
26         );
27     }
28
29     public YearMonthIntegerType(Configuration configuration) {
30         super(
31             IntegerTypeDescriptor.INSTANCE,
32             YearMonthTypeDescriptor.INSTANCE,
33             configuration
34         );
35     }
36
37     public String getName() {
38         return "yearmonth-int";
39     }
40
41     @Override
42     protected boolean registerUnderJavaType() {
43         return true;
44     }
45 }