I think I found code for a custom type that handles Oracle LONG columns in one of the hibernate wiki pages. I'd post the linke instead of this, but I can't remember where I found it. Create a class like this:
Code:
package yourpackage;
import net.sf.hibernate.*;
import java.sql.*;
import java.io.*;
public class LongType
implements UserType {
public LongType() {
}
public int[] sqlTypes() {
return new int[] {
java.sql.Types.LONGVARCHAR};
}
public Class returnedClass() {
return java.lang.String.class;
}
public boolean equals(Object x, Object y) throws HibernateException {
return (x == y)
|| (x != null
&& y != null
&& (x.equals(y)));
}
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws
HibernateException, SQLException {
Object out = "";
try {
InputStream stream = rs.getAsciiStream(names[0]);
byte[] buff = new byte[1024];
int len = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
while ( (len = stream.read(buff, 0, 1024)) > -1) {
bos.write(buff, 0, len);
}
out = bos.toString();
}
catch (IOException ex) {
//worth printing b/c this means a failure occurred reading from stream
ex.printStackTrace();
}
catch (Throwable t) {
//eat this exception b/c it is of no interest (i.e. stream is null for null attribute value)
}
return out;
}
public void nullSafeSet(PreparedStatement st, Object value, int index) throws
HibernateException, SQLException {
try {
String s = (String)value;
if (s == null)
s = "";
InputStream is = new ByteArrayInputStream(s.getBytes());
st.setAsciiStream(index, is, s.length());
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public Object deepCopy(Object value) throws HibernateException {
if (value == null) {
return null;
}
return new String( (String) value);
}
public boolean isMutable() {
return false;
}
}
In your mapping file, use type="yourpackage.LongType" and you should be good to go.