CustomTypepublic class CustomType extends AbstractType implements DiscriminatorType, IdentifierType, VersionTypeAdapts {@link UserType} to the generic {@link Type} interface, in order
to isolate user code from changes in the internal Type contracts. |
Fields Summary |
---|
private final org.hibernate.usertype.UserType | userType | private final String | name | private final int[] | types | private final boolean | customLogging |
Constructors Summary |
---|
public CustomType(Class userTypeClass, Properties parameters)
if ( !UserType.class.isAssignableFrom( userTypeClass ) ) {
throw new MappingException(
"Custom type does not implement UserType: " +
userTypeClass.getName()
);
}
name = userTypeClass.getName();
try {
userType = ( UserType ) userTypeClass.newInstance();
}
catch ( InstantiationException ie ) {
throw new MappingException(
"Cannot instantiate custom type: " +
userTypeClass.getName()
);
}
catch ( IllegalAccessException iae ) {
throw new MappingException(
"IllegalAccessException trying to instantiate custom type: " +
userTypeClass.getName()
);
}
TypeFactory.injectParameters( userType, parameters );
types = userType.sqlTypes();
customLogging = LoggableUserType.class.isAssignableFrom( userTypeClass );
|
Methods Summary |
---|
public java.lang.Object | assemble(java.io.Serializable cached, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)
return userType.assemble(cached, owner);
| public java.lang.Object | deepCopy(java.lang.Object value, org.hibernate.EntityMode entityMode, org.hibernate.engine.SessionFactoryImplementor factory)
return userType.deepCopy(value);
| public java.io.Serializable | disassemble(java.lang.Object value, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)
return userType.disassemble(value);
| public java.lang.Object | fromXMLNode(org.dom4j.Node xml, org.hibernate.engine.Mapping factory)
return fromXMLString( xml.getText(), factory );
| public java.lang.Object | fromXMLString(java.lang.String xml, org.hibernate.engine.Mapping factory)
return ( (EnhancedUserType) userType ).fromXMLString(xml);
| public int | getColumnSpan(org.hibernate.engine.Mapping session)
return types.length;
| public java.util.Comparator | getComparator()
return (Comparator) userType;
| public int | getHashCode(java.lang.Object x, org.hibernate.EntityMode entityMode)
return userType.hashCode(x);
| public java.lang.String | getName()
return name;
| public java.lang.Class | getReturnedClass()
return userType.returnedClass();
| public boolean | isDirty(java.lang.Object old, java.lang.Object current, boolean[] checkable, org.hibernate.engine.SessionImplementor session)
return checkable[0] && isDirty(old, current, session);
| public boolean | isEqual(java.lang.Object x, java.lang.Object y)
return userType.equals(x, y);
| public boolean | isEqual(java.lang.Object x, java.lang.Object y, org.hibernate.EntityMode entityMode)
return isEqual(x, y);
| public boolean | isMutable()
return userType.isMutable();
| public java.lang.Object | next(java.lang.Object current, org.hibernate.engine.SessionImplementor session)
return ( (UserVersionType) userType ).next( current, session );
| public java.lang.Object | nullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)
return userType.nullSafeGet(rs, names, owner);
| public java.lang.Object | nullSafeGet(java.sql.ResultSet rs, java.lang.String columnName, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)
return nullSafeGet(rs, new String[] { columnName }, session, owner);
| public void | nullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, boolean[] settable, org.hibernate.engine.SessionImplementor session)
if ( settable[0] ) userType.nullSafeSet(st, value, index);
| public void | nullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, org.hibernate.engine.SessionImplementor session)
userType.nullSafeSet(st, value, index);
| public java.lang.String | objectToSQLString(java.lang.Object value, org.hibernate.dialect.Dialect dialect)
return ( (EnhancedUserType) userType ).objectToSQLString(value);
| public java.lang.Object | replace(java.lang.Object original, java.lang.Object target, org.hibernate.engine.SessionImplementor session, java.lang.Object owner, java.util.Map copyCache)
return userType.replace(original, target, owner);
| public java.lang.Object | seed(org.hibernate.engine.SessionImplementor session)
return ( (UserVersionType) userType ).seed( session );
| public void | setToXMLNode(org.dom4j.Node node, java.lang.Object value, org.hibernate.engine.SessionFactoryImplementor factory)
node.setText( toXMLString(value, factory) );
| public int[] | sqlTypes(org.hibernate.engine.Mapping pi)
return types;
| public java.lang.Object | stringToObject(java.lang.String xml)
return ( (EnhancedUserType) userType ).fromXMLString(xml);
| public boolean[] | toColumnNullness(java.lang.Object value, org.hibernate.engine.Mapping mapping)
boolean[] result = new boolean[ getColumnSpan(mapping) ];
if (value!=null) Arrays.fill(result, true);
return result;
| public java.lang.String | toLoggableString(java.lang.Object value, org.hibernate.engine.SessionFactoryImplementor factory)
if ( value == null ) {
return "null";
}
else if ( customLogging ) {
return ( ( LoggableUserType ) userType ).toLoggableString( value, factory );
}
else {
return toXMLString( value, factory );
}
| public java.lang.String | toXMLString(java.lang.Object value, org.hibernate.engine.SessionFactoryImplementor factory)
if (value==null) return null;
if (userType instanceof EnhancedUserType) {
return ( (EnhancedUserType) userType ).toXMLString(value);
}
else {
return value.toString();
}
|
|