org.hibernate.type.DiscriminatorType Java Examples

The following examples show how to use org.hibernate.type.DiscriminatorType. 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: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void bindAny(Element node, Any any, boolean isNullable, Mappings mappings)
		throws MappingException {
	any.setIdentifierType( getTypeFromXML( node ) );
	Attribute metaAttribute = node.attribute( "meta-type" );
	if ( metaAttribute != null ) {
		any.setMetaType( metaAttribute.getValue() );

		Iterator iter = node.elementIterator( "meta-value" );
		if ( iter.hasNext() ) {
			HashMap values = new HashMap();
			org.hibernate.type.Type metaType = TypeFactory.heuristicType( any.getMetaType() );
			while ( iter.hasNext() ) {
				Element metaValue = (Element) iter.next();
				try {
					Object value = ( (DiscriminatorType) metaType ).stringToObject( metaValue
						.attributeValue( "value" ) );
					String entityName = getClassName( metaValue.attribute( "class" ), mappings );
					values.put( value, entityName );
				}
				catch (ClassCastException cce) {
					throw new MappingException( "meta-type was not a DiscriminatorType: "
						+ metaType.getName() );
				}
				catch (Exception e) {
					throw new MappingException( "could not interpret meta-value", e );
				}
			}
			any.setMetaValues( values );
		}

	}

	bindColumns( node, any, isNullable, false, null, mappings );
}