TextTypepublic class TextType extends ImmutableType text: A type that maps an SQL CLOB to a Java String. |
Methods Summary |
---|
public java.lang.Object | fromStringValue(java.lang.String xml)
return xml;
| public java.lang.Object | get(java.sql.ResultSet rs, java.lang.String name)
// Retrieve the value of the designated column in the current row of this
// ResultSet object as a java.io.Reader object
Reader charReader = rs.getCharacterStream(name);
// if the corresponding SQL value is NULL, the reader we got is NULL as well
if (charReader==null) return null;
// Fetch Reader content up to the end - and put characters in a StringBuffer
StringBuffer sb = new StringBuffer();
try {
char[] buffer = new char[2048];
while (true) {
int amountRead = charReader.read(buffer, 0, buffer.length);
if ( amountRead == -1 ) break;
sb.append(buffer, 0, amountRead);
}
}
catch (IOException ioe) {
throw new HibernateException( "IOException occurred reading text", ioe );
}
finally {
try {
charReader.close();
}
catch (IOException e) {
throw new HibernateException( "IOException occurred closing stream", e );
}
}
// Return StringBuffer content as a large String
return sb.toString();
| public java.lang.String | getName() return "text";
| public java.lang.Class | getReturnedClass()
return String.class;
| public void | set(java.sql.PreparedStatement st, java.lang.Object value, int index)
String str = (String) value;
st.setCharacterStream( index, new StringReader(str), str.length() );
| public int | sqlType()
return Types.CLOB; //or Types.LONGVARCHAR?
| public java.lang.String | toString(java.lang.Object val)
return (String) val;
|
|