http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/
I am attempting to defined a customer serialization UserType that mimics, the XStreamUserType referenced and provided here:
http://code.google.com/p/aphillips/source/browse/commons-hibernate-usertype/trunk/src/main/java/com/qrmedia/commons/persistence/hibernate/usertype/XStreamableUserType.java
My serializer outputs a bytearray that should presumably written to a Blob. I was going to do:
public class CustomSerUserType extends DirtyCheckableUserType {
protected SerA ser=F.g(SerA.class);
public Class<Object> returnedClass() {
return Object.class;
}
public int[] sqlTypes() {
return new int[] {Types.BLOB};
}
public Object nullSafeGet(ResultSet resultSet,String[] names,Object owner)
throws HibernateException,SQLException {
if()
}
public void nullSafeSet(PreparedStatement preparedStatement,Object value,int index)
throws HibernateException,SQLException {
BlobType.nullSafeSet(preparedStatement,ser.ser(value),index);
}
}
Unfortunetly, the BlobType.nullSafeSet method requires the session. So how does one define a UserType that gets access to a servlet requests session?
EDIT: There is a discussion of the issue here and it doesn't appear there is a solution: Best way to implement a Hibernate UserType after deprecations?