What to pass to UserType, BlobType.setPreparedStatement session parameter
Posted
by
dlots
on Stack Overflow
See other posts from Stack Overflow
or by dlots
Published on 2012-04-09T22:53:04Z
Indexed on
2012/04/09
23:28 UTC
Read the original article
Hit count: 327
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:
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?
© Stack Overflow or respective owner