I'm getting warnings in my log file to the effect of:
Code:
13:15:14,335 WARN CustomType:49 - custom type does not implement Serializable: class com.foo.bar.TimeIntervalUserType
My TimeInterval class implements Serializable but the TimeIntervalUserType does not. The code in net.sf.hibernate.type.CustomType seems to want the UserType to be Serializable:
Code:
public CustomType(Class userTypeClass) throws MappingException {
name = userTypeClass.getName();
try {
userType = (UserType)userTypeClass.newInstance();
}
catch(InstantiationException ie) {
throw new MappingException("Cannot instantiate custom type: " + userTypeClass.getName());
}
catch(IllegalAccessException iae) {
throw new MappingException("IllegalAccessException trying to instantiate custom type: " + userTypeClass.getName());
}
catch(ClassCastException cce) {
throw new MappingException(userTypeClass.getName() + " must implement net.sf.hibernate.UserType");
}
types = userType.sqlTypes();
if(!(java.io.Serializable.class).isAssignableFrom(userType.returnedClass())) {
LogFactory.getLog(net.sf.hibernate.type.CustomType.class).warn("custom type does not implement Serializable: " + userTypeClass);
}
}
but the section in
Hibernate In Action that describes UserType (Section 6.1.2) doesn't mention anything about custom user types having to be serializable. I'd appreciate it if someone could resolve the discrepency and maybe even explain why UserTypes need to be Serializable (if indeed they do).
Thanks,
Alex