1 package org.hibernate.type; 3 4 import java.math.BigDecimal ; 5 import java.sql.PreparedStatement ; 6 import java.sql.ResultSet ; 7 import java.sql.SQLException ; 8 import java.sql.Types ; 9 10 import org.hibernate.EntityMode; 11 import org.hibernate.HibernateException; 12 13 19 public class BigDecimalType extends ImmutableType { 20 21 public Object get(ResultSet rs, String name) 22 throws HibernateException, SQLException { 23 return rs.getBigDecimal(name); 24 } 25 26 public void set(PreparedStatement st, Object value, int index) 27 throws HibernateException, SQLException { 28 st.setBigDecimal(index, (BigDecimal ) value); 29 } 30 31 public int sqlType() { 32 return Types.NUMERIC; 33 } 34 35 public String toString(Object value) throws HibernateException { 36 return value.toString(); 37 } 38 39 public Class getReturnedClass() { 40 return BigDecimal .class; 41 } 42 43 public boolean isEqual(Object x, Object y) { 44 return x==y || ( x!=null && y!=null && ( (BigDecimal ) x ).compareTo( (BigDecimal ) y )==0 ); 45 } 46 47 public int getHashCode(Object x, EntityMode entityMode) { 48 return ( (BigDecimal ) x ).intValue(); 49 } 50 51 public String getName() { 52 return "big_decimal"; 53 } 54 55 public Object fromStringValue(String xml) { 56 return new BigDecimal (xml); 57 } 58 59 60 } 61 62 63 64 65 66 67 | Popular Tags |