01: //$Id: DoubleType.java 7825 2005-08-10 20:23:55Z oneovthafew $
02: package org.hibernate.type;
03:
04: import java.io.Serializable;
05: import java.sql.PreparedStatement;
06: import java.sql.ResultSet;
07: import java.sql.SQLException;
08: import java.sql.Types;
09:
10: import org.hibernate.dialect.Dialect;
11:
12: /**
13: * <tt>double</tt>: A type that maps an SQL DOUBLE to a Java Double.
14: * @author Gavin King
15: */
16: public class DoubleType extends PrimitiveType {
17:
18: public Serializable getDefaultValue() {
19: return new Double(0.0);
20: }
21:
22: public Object get(ResultSet rs, String name) throws SQLException {
23: return new Double(rs.getDouble(name));
24: }
25:
26: public Class getPrimitiveClass() {
27: return double.class;
28: }
29:
30: public Class getReturnedClass() {
31: return Double.class;
32: }
33:
34: public void set(PreparedStatement st, Object value, int index)
35: throws SQLException {
36:
37: st.setDouble(index, ((Double) value).doubleValue());
38: }
39:
40: public int sqlType() {
41: return Types.DOUBLE;
42: }
43:
44: public String getName() {
45: return "double";
46: }
47:
48: public String objectToSQLString(Object value, Dialect dialect)
49: throws Exception {
50: return value.toString();
51: }
52:
53: public Object fromStringValue(String xml) {
54: return new Double(xml);
55: }
56:
57: }
|