You are the man!
That worked.
Now how am I supposed to make my code platform independent and work with different dialects?
Here is my nullSafeGet method which is mapping a List of objects to an Oracle type defined as TANGO.STRING_ARRAY which is a TABLE OF VARCHAR2(255)
public void nullSafeSet(PreparedStatement statement, Object value, int index)
throws HibernateException, SQLException {
if (value == null)
statement.setNull(index, SQL_TYPES[0]);
else if(value instanceof ARRAY){
statement.setArray(index, (ARRAY) value);
}
else if(value instanceof List)
{
List valueList = (List)value;
String[] stringArray = new String[valueList.size()];
valueList.toArray(stringArray);
ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("TANGO.STRING_ARRAY", statement.getConnection());
ARRAY array = new oracle.sql.ARRAY(arrayDesc, statement.getConnection(), stringArray);
statement.setArray(index, array);
}
}
|