I am using a UserType to map Clob to String , the code is similar to the example provided in
http://hibernate.bluemars.net/76.html.
The nullsafeget method is like this:
public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
throws HibernateException, SQLException
{
Clob clob = rs.getClob(names[0]);
return clob.getSubString(1, (int) clob.length());
}
The mapping class is :
public class Dummy
{
String id;
String longText ; //mapped to Clob in DB
// get set methods
}
The mapping file entry is :
<property column="TEXT" name="longText" type="org.SafeClobType"/>
Things work fine when i load the entire object.
"from c in class Dummy where <some condition>" works fine
It does not work when I have a scalar query.
"select c.text from c in class Dummy where <some condition>" fails. nullSafeGet method throws ArrayIndexOutOfBoundsException.
The reason being the names[] array length is zero.
Thanks for any suggestions.