<id name="id" type="xxCompositeUserType">
<column name="c1"/>
<column name="c2" />
</id>
public class DoubleIntegerType implements CompositeUserType {
private static final int[] TYPES = { Types.INTEGER, Types.INTEGER };
public int[] sqlTypes() {
return TYPES;
}
public String[] getPropertyNames() {
return new String[] {"integer1", "integer2"};
}
public Type[] getPropertyTypes() {
return new Type[] {Hibernate.INTEGER, Hibernate.INTEGER};
}
public Object getPropertyValue(Object component, int property)
throws HibernateException {
return ((Integer[]) component)[property];
}
public void setPropertyValue(Object component, int property, Object value)
throws HibernateException {
( (Integer[]) component )[property] = (Integer) value;
}
public Class returnedClass() {
return Integer[].class;
}
public boolean equals(Object x, Object y) throws HibernateException {
if (x == y) {
return true;
}
if (x == null || y == null) {
return false;
}
Integer[] i1 = (Integer[]) x;
Integer[] i2 = (Integer[]) y;
return ( i1[0].equals(i2[0]) && i1[1].equals(i2[1]) );
}
public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner) throws HibernateException,
SQLException {
Integer first = (Integer) Hibernate.INTEGER.nullSafeGet(rs, names[0]);
Integer second = (Integer) Hibernate.INTEGER.nullSafeGet(rs, names[1]);
return ( first==null && second==null ) ? null : new Integer[] { first, second };
}
public void nullSafeSet(PreparedStatement st, Object value, int index,
SessionImplementor session) throws HibernateException, SQLException {
Integer[] integers = (value==null) ? new Integer[2] : (Integer[]) value;
Hibernate.INTEGER.nullSafeSet(st, integers[0], index);
Hibernate.INTEGER.nullSafeSet(st, integers[1], index+1);
}
public Object deepCopy(Object value) throws HibernateException {
if ( value==null ) return null;
Integer[] result = new Integer[2];
Integer[] input = (Integer[]) value;
result[0] = input[0];
result[1] = input[1];
return result;
}
public boolean isMutable() {
return true;
}
public Serializable disassemble(Object value, SessionImplementor session)
throws HibernateException {
return (Serializable) deepCopy(value);
}
public Object assemble(Serializable cached, SessionImplementor session,
Object owner) throws HibernateException {
return deepCopy(cached);
}
}
<column name="c1"/>
<column name="c2" />
</id>
public class DoubleIntegerType implements CompositeUserType {
private static final int[] TYPES = { Types.INTEGER, Types.INTEGER };
public int[] sqlTypes() {
return TYPES;
}
public String[] getPropertyNames() {
return new String[] {"integer1", "integer2"};
}
public Type[] getPropertyTypes() {
return new Type[] {Hibernate.INTEGER, Hibernate.INTEGER};
}
public Object getPropertyValue(Object component, int property)
throws HibernateException {
return ((Integer[]) component)[property];
}
public void setPropertyValue(Object component, int property, Object value)
throws HibernateException {
( (Integer[]) component )[property] = (Integer) value;
}
public Class returnedClass() {
return Integer[].class;
}
public boolean equals(Object x, Object y) throws HibernateException {
if (x == y) {
return true;
}
if (x == null || y == null) {
return false;
}
Integer[] i1 = (Integer[]) x;
Integer[] i2 = (Integer[]) y;
return ( i1[0].equals(i2[0]) && i1[1].equals(i2[1]) );
}
public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner) throws HibernateException,
SQLException {
Integer first = (Integer) Hibernate.INTEGER.nullSafeGet(rs, names[0]);
Integer second = (Integer) Hibernate.INTEGER.nullSafeGet(rs, names[1]);
return ( first==null && second==null ) ? null : new Integer[] { first, second };
}
public void nullSafeSet(PreparedStatement st, Object value, int index,
SessionImplementor session) throws HibernateException, SQLException {
Integer[] integers = (value==null) ? new Integer[2] : (Integer[]) value;
Hibernate.INTEGER.nullSafeSet(st, integers[0], index);
Hibernate.INTEGER.nullSafeSet(st, integers[1], index+1);
}
public Object deepCopy(Object value) throws HibernateException {
if ( value==null ) return null;
Integer[] result = new Integer[2];
Integer[] input = (Integer[]) value;
result[0] = input[0];
result[1] = input[1];
return result;
}
public boolean isMutable() {
return true;
}
public Serializable disassemble(Object value, SessionImplementor session)
throws HibernateException {
return (Serializable) deepCopy(value);
}
public Object assemble(Serializable cached, SessionImplementor session,
Object owner) throws HibernateException {
return deepCopy(cached);
}
}