1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jadira.usertype.spi.shared;
17
18 import java.sql.Time;
19 import java.util.Calendar;
20 import java.util.Date;
21
22 import org.hibernate.dialect.Dialect;
23 import org.hibernate.type.AbstractSingleColumnStandardBasicType;
24 import org.hibernate.type.LiteralType;
25 import org.hibernate.type.StringType;
26 import org.hibernate.type.descriptor.java.JdbcTimeTypeDescriptor;
27 import org.jadira.usertype.spi.shared.descriptor.sql.DstSafeTimeTypeDescriptor;
28
29
30
31
32 @Deprecated
33 public class DstSafeTimeType extends
34 AbstractSingleColumnStandardBasicType<Date> implements
35 LiteralType<Date> {
36
37 private static final long serialVersionUID = -3665273920874664942L;
38
39 public static final DstSafeTimeType INSTANCE = new DstSafeTimeType();
40
41 public DstSafeTimeType() {
42 super(DstSafeTimeTypeDescriptor.INSTANCE,
43 JdbcTimeTypeDescriptor.INSTANCE);
44 }
45
46 public DstSafeTimeType(Calendar cal) {
47 super(cal == null ? DstSafeTimeTypeDescriptor.INSTANCE : new DstSafeTimeTypeDescriptor(cal),
48 JdbcTimeTypeDescriptor.INSTANCE);
49 }
50
51 public String getName() {
52 return "dstSafeTime";
53 }
54
55 @Override
56 public String[] getRegistrationKeys() {
57 return new String[] { getName(), java.sql.Time.class.getName() };
58 }
59
60 public String objectToSQLString(Date value, Dialect dialect)
61 throws Exception {
62 final Time ts = Time.class.isInstance(value) ? (Time) value : new Time(
63 value.getTime());
64
65
66 return StringType.INSTANCE.objectToSQLString(ts.toString(), dialect);
67 }
68 }