I'm getting this exception, and I dont understand WHY
Quote:
java.lang.ExceptionInInitializerError
Caused by: org.hibernate.MappingException: Could not determine type for: DAType, for columns: [org.hibernate.mapping.Column(DA)]
My usertype is very simple - it takes a class, and stores its .toString() to the database. the Constructor takes the string to re-build the object.
Can anone see where I've gone wrong?
My other usertypes work, so I cant see whats wrong with this one,
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="DATest" table="TEST">
<id name="id" type="int" column="ID">
<generator class="native"/>
</id>
<property name="da" type="DAType">
<column name="DA"/>
</property>
</class>
</hibernate-mapping>
Code:
public class DAType implements UserType {
public static final int[] SQL_TYPES ={Types.VARCHAR};
public Object assemble(Serializable value, Object parent)
throws HibernateException {
return new DA((String)value);
}
public Serializable disassemble(Object value) throws HibernateException {
DA da = (DigestAlgorithm)value;
return da.toString();
}
public Object deepCopy(Object value) throws HibernateException {
return value.toString();
}
public boolean equals(Object arg0, Object arg1) throws HibernateException {
return arg0.equals(arg1);
}
public int hashCode(Object arg0) throws HibernateException {
return arg0.hashCode();
}
public boolean isMutable() {
return false;
}
public Object nullSafeGet(ResultSet results, String[] columnNames, Object Owner)
throws HibernateException, SQLException {
String value = results.getString(results.findColumn(columnNames[0]));
return assemble(value, null);
}
public void nullSafeSet(PreparedStatement st, Object value, int index)
throws HibernateException, SQLException {
st.setString(index, (String)disassemble(value));
}
public Object replace(Object target, Object original, Object parent)
throws HibernateException {
target = original;
return original;
}
public Class returnedClass() {
return DA.class;
}
public int[] sqlTypes() {
return SQL_TYPES;
}
}
Code:
public class DA{
int i;
public DA(String num){
j = Integer.getInteger(num);
i = j.intValue();
}