1 package org.hibernate.type; 3 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 StringType extends ImmutableType implements DiscriminatorType { 14 15 public Object get(ResultSet rs, String name) throws SQLException { 16 return rs.getString(name); 17 } 18 19 public Class getReturnedClass() { 20 return String .class; 21 } 22 23 public void set(PreparedStatement st, Object value, int index) throws SQLException { 24 st.setString(index, (String ) value); 25 } 26 27 public int sqlType() { 28 return Types.VARCHAR; 29 } 30 31 public String getName() { return "string"; } 32 33 public String objectToSQLString(Object value) throws Exception { 34 return '\'' + (String ) value + '\''; 35 } 36 37 public Object stringToObject(String xml) throws Exception { 38 return xml; 39 } 40 41 public String toString(Object value) { 42 return (String ) value; 43 } 44 45 public Object fromStringValue(String xml) { 46 return xml; 47 } 48 49 } 50 51 52 53 54 55 | Popular Tags |