View Javadoc
1   /*
2    *  Copyright 2010, 2011, 2012 Christopher Pheby
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.jadira.usertype.spi.shared;
17  
18  import java.math.BigDecimal;
19  import java.sql.Types;
20  
21  import org.hibernate.type.BigDecimalType;
22  import org.hibernate.type.StandardBasicTypes;
23  
24  public abstract class AbstractBigDecimalColumnMapper<T> extends AbstractColumnMapper<T, BigDecimal> {
25  
26      private static final long serialVersionUID = 1702998875351962961L;
27  
28      @Override
29      public final int getSqlType() {
30          return Types.NUMERIC;
31      }
32  
33      @Override
34      public final BigDecimalType getHibernateType() {
35      	return StandardBasicTypes.BIG_DECIMAL;
36      }
37  
38      @Override
39      public abstract T fromNonNullValue(BigDecimal value);
40  
41      @Override
42      public abstract T fromNonNullString(String s);
43  
44      @Override
45      public abstract BigDecimal toNonNullValue(T value);
46  
47      @Override
48      public abstract String toNonNullString(T value);
49  }