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 import org.hibernate.type.descriptor.sql.TimestampTypeDescriptor;
8
9 import java.time.YearMonth;
10
11 /**
12  * Maps a Java {@link YearMonth} object to a {@code TIMESTAMP} column type.
13  * <p>
14  *
15  * @author Vlad Mihalcea
16  */

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