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