tenwit wrote:
Oh yea, two seperate issues in one post, I missed that. The ant error is presumably beacuse your ParameterTypeUserType class either is not present in the location you specified, or else it doesn't implement the UserType interface. Whatever jar is providing the ParameterTypeUserType needs to be accessible to ant.. that is, it should be on your classpath.
The ParameterTypeUserType class implements UserType as follows:
package models.customtypes;
import org.hibernate.usertype.*;
import org.hibernate.*;
import java.sql.*;
import java.io.*;
import models.*;
public class ParameterTypeUserType implements UserType {
private static final int[] SQL_TYPES = {Types.VARCHAR};
public int[] sqlTypes() {return SQL_TYPES;}
public Class returnedClass() {return ParameterType.class;}
public boolean equals(Object x, Object y) {return x == y;}
public Object deepCopy(Object value) {return value;}
public boolean isMutable() {return false;}
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner)
throws HibernateException, SQLException{
String type = resultSet.getString(names[0]);
if (resultSet.wasNull()){
return null;
}
else{
return ParameterType.getInstance(type);
}
}
public void nullSafeSet(PreparedStatement statement, Object value, int index)
throws HibernateException, SQLException{
if(value==null){
statement.setNull(index, Types.VARCHAR);
}
else{
statement.setString(index, value.toString());
}
}
public int hashCode(Object o){
return o.hashCode();
}
public Serializable disassemble (Object value){
return (Serializable) deepCopy(value);
}
public Object assemble(Serializable cached, Object owner){
return deepCopy(cached);
}
public Object replace(Object original, Object target, Object owner)
throws HibernateException{
return original;
}
}
And it's located in the package models.customtypes. So I think the path in the mapping file should be ok, or isn't it?
What do you mean by 'need to be accesible to ant'? Which classpath I have to set in the build.xml file? (Sorry, I'm new to hibernate and this stuff)
Thanks