1 package org.hibernate.type; 3 import java.io.Serializable ; 4 import java.sql.PreparedStatement ; 5 import java.sql.ResultSet ; 6 import java.sql.SQLException ; 7 import java.sql.Types ; 8 9 13 public class DoubleType extends PrimitiveType { 14 15 public Serializable getDefaultValue() { 16 return new Double (0.0); 17 } 18 19 public Object get(ResultSet rs, String name) throws SQLException { 20 return new Double ( rs.getDouble(name) ); 21 } 22 23 public Class getPrimitiveClass() { 24 return double.class; 25 } 26 27 public Class getReturnedClass() { 28 return Double .class; 29 } 30 31 public void set(PreparedStatement st, Object value, int index) 32 throws SQLException { 33 34 st.setDouble( index, ( (Double ) value ).doubleValue() ); 35 } 36 37 public int sqlType() { 38 return Types.DOUBLE; 39 } 40 public String getName() { return "double"; } 41 42 public String objectToSQLString(Object value) throws Exception { 43 return value.toString(); 44 } 45 46 public Object fromStringValue(String xml) { 47 return new Double (xml); 48 } 49 50 } 51 52 53 54 55 56 | Popular Tags |