1 package org.jbpm.db.hibernate; 2 3 import java.io.*; 4 import java.sql.*; 5 6 import org.hibernate.*; 7 import org.hibernate.usertype.*; 8 import org.jbpm.context.exe.*; 9 10 14 public class ConverterEnumType implements UserType { 15 16 static final int[] SQLTYPES = new int[]{Types.CHAR}; 17 18 public boolean equals(Object o1, Object o2) { return (o1==o2); } 19 public int hashCode(Object o) throws HibernateException { return o.hashCode(); } 20 public Object deepCopy(Object o) throws HibernateException { return o; } 21 public boolean isMutable() { return false; } 22 public Serializable disassemble(Object o) throws HibernateException { return (Serializable) o; } 23 public Object assemble(Serializable s, Object o) throws HibernateException { return s; } 24 public Object replace(Object original, Object target, Object owner) { return target; } 25 public int[] sqlTypes() { return SQLTYPES; } 26 public Class returnedClass() { return Converter.class; } 27 28 public Object nullSafeGet(ResultSet resultSet, String [] names, Object owner) throws HibernateException, SQLException { 29 String converterDatabaseId = resultSet.getString(names[0]); 30 return Converters.getConverterByDatabaseId(converterDatabaseId); 31 } 32 33 public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { 34 String converterDatabaseId = Converters.getConverterId((Converter) value); 35 preparedStatement.setString(index, converterDatabaseId); 36 } 37 } 38 | Popular Tags |