1 package com.vladmihalcea.hibernate.type.basic;
2
3 import com.vladmihalcea.hibernate.type.AbstractHibernateType;
4 import com.vladmihalcea.hibernate.type.basic.internal.YearMonthEpochTypeDescriptor;
5 import com.vladmihalcea.hibernate.type.util.Configuration;
6 import org.hibernate.type.descriptor.sql.SmallIntTypeDescriptor;
7
8 import java.time.YearMonth;
9
10 /**
11  * Maps a Java {@link YearMonth} object to an small and continuous {@code INT} column type
12  * which defines the months that passed since the Unix epoch.
13  *
14  * @author Vlad Mihalcea
15  */

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