I've a UserType to handle NULL values for booleans as false. It works fine.
Up on start-up Hibernate complains that it doesn't implement the Serializable interface also it does.
Any ideas?
Ernst
Debug level Hibernate log excerpt:
Code:
...
WARNUNG CustomType <init>: custom type does not implement Serializable: class ch.bedag.gba.cap.server.persistence.hibernate.BooleanPersistentType
...
Implementation of the BooleanPersistentTypeCode:
public class BooleanPersistentType implements Serializable, UserType {
private static final ch.bedag.gba.common.logging.CapiLogger LOG = ch.bedag.gba.common.logging.CapiLoggerFactory
.getLog(BooleanPersistentType.class);
public BooleanPersistentType(){
super();
}
public int[] sqlTypes() {
return new int[]{Types.SMALLINT};
}
public Class returnedClass() {
return boolean.class;
}
public boolean equals(Object x, Object y) throws HibernateException {
if (x == y) return true;
if (x == null || y == null) return false;
return x.equals(y);
}
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
Integer i = (Integer) Hibernate.INTEGER.nullSafeGet(rs, names);
if (i==null || i.intValue()==0) {
return Boolean.FALSE;
}
else {
return Boolean.TRUE;
}
}
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
if (value==null) value = Boolean.FALSE;
Boolean b = (Boolean)value;
if (Boolean.TRUE.equals(b)) {
st.setInt(index, 1);
}
else {
st.setInt(index, 0);
}
}
public Object deepCopy(Object value) throws HibernateException {
return value;
}
public boolean isMutable() {
return true;
}
}
Hibernate version: 2.1.7 (Nightly Snapshot of 4.10.2004)
Mapping documents:Code:
...
<property name="myGueltig" column="FBF08" access="field" type="ch.bedag.gba.cap.server.persistence.hibernate.BooleanPersistentType"/>
...
Name and version of the database you are using:
Oracle 9.2