http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/
ここで参照および提供されている XStreamUserType を模倣する顧客のシリアル化 UserType を定義しようとしています。
私のシリアライザーは、おそらく Blob に書き込まれるはずの bytearray を出力します。私はやろうとしていた:
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);
}
}
残念ながら、BlobType.nullSafeSet メソッドにはセッションが必要です。では、サーブレット リクエスト セッションにアクセスする UserType をどのように定義すればよいでしょうか。
編集:ここで問題の議論があり、解決策があるようには見えません:非推奨の後に Hibernate UserType を実装する最良の方法?