org.hibernate.usertype.EnhancedUserType Java Examples

The following examples show how to use org.hibernate.usertype.EnhancedUserType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomType.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object fromStringValue(String string) throws HibernateException {
	if ( StringRepresentableType.class.isInstance( getUserType() ) ) {
		return ( (StringRepresentableType) getUserType() ).fromStringValue( string );
	}
	if ( EnhancedUserType.class.isInstance( getUserType() ) ) {
		//noinspection deprecation
		return ( (EnhancedUserType) getUserType() ).fromXMLString( string );
	}
	throw new HibernateException(
			String.format(
					"Could not process #fromStringValue, UserType class [%s] did not implement %s or %s",
					name,
					StringRepresentableType.class.getName(),
					EnhancedUserType.class.getName()
			)
	);
}
 
Example #2
Source File: CustomType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public String toString(Object value) throws HibernateException {
	if ( StringRepresentableType.class.isInstance( getUserType() ) ) {
		return ( (StringRepresentableType) getUserType() ).toString( value );
	}
	if ( value == null ) {
		return null;
	}
	if ( EnhancedUserType.class.isInstance( getUserType() ) ) {
		//noinspection deprecation
		return ( (EnhancedUserType) getUserType() ).toXMLString( value );
	}
	return value.toString();
}
 
Example #3
Source File: CustomType.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String toXMLString(Object value, SessionFactoryImplementor factory) {
	if (value==null) return null;
	if (userType instanceof EnhancedUserType) {
		return ( (EnhancedUserType) userType ).toXMLString(value);
	}
	else {
		return value.toString();
	}
}
 
Example #4
Source File: CustomType.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String objectToSQLString(Object value, Dialect dialect) throws Exception {
	return ( (EnhancedUserType) getUserType() ).objectToSQLString( value);
}
 
Example #5
Source File: CustomType.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Object fromXMLString(String xml, Mapping factory) {
	return ( (EnhancedUserType) userType ).fromXMLString(xml);
}
 
Example #6
Source File: CustomType.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Object stringToObject(String xml) {
	return ( (EnhancedUserType) userType ).fromXMLString(xml);
}
 
Example #7
Source File: CustomType.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public String objectToSQLString(Object value, Dialect dialect) throws Exception {
	return ( (EnhancedUserType) userType ).objectToSQLString(value);
}