Java 类org.hibernate.type.DiscriminatorType 实例源码

项目:lams    文件:HbmBinder.java   
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 = mappings.getTypeResolver().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 );
}
项目:cacheonix-core    文件:HbmBinder.java   
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 );
}