Java 类org.hibernate.property.PropertyAccessorFactory 实例源码

项目:lams    文件:AliasToBeanResultTransformer.java   
private void initialize(String[] aliases) {
    PropertyAccessor propertyAccessor = new ChainedPropertyAccessor(
            new PropertyAccessor[] {
                    PropertyAccessorFactory.getPropertyAccessor( resultClass, null ),
                    PropertyAccessorFactory.getPropertyAccessor( "field" )
            }
    );
    this.aliases = new String[ aliases.length ];
    setters = new Setter[ aliases.length ];
    for ( int i = 0; i < aliases.length; i++ ) {
        String alias = aliases[ i ];
        if ( alias != null ) {
            this.aliases[ i ] = alias;
            setters[ i ] = propertyAccessor.getSetter( resultClass, alias );
        }
    }
    isInitialized = true;
}
项目:cacheonix-core    文件:Dom4jAccessorTest.java   
public void testCompanyElementGeneration() throws Throwable {
    Setter idSetter = PropertyAccessorFactory.getPropertyAccessor( generateIdProperty(), EntityMode.DOM4J )
            .getSetter( null, null );
    Setter nameSetter = PropertyAccessorFactory.getPropertyAccessor( generateNameProperty(), EntityMode.DOM4J )
            .getSetter( null, null );
    Setter textSetter = PropertyAccessorFactory.getPropertyAccessor( generateTextProperty(), EntityMode.DOM4J )
            .getSetter( null, null );
    Setter accountIdSetter = PropertyAccessorFactory.getPropertyAccessor(
            generateAccountIdProperty(), EntityMode.DOM4J
    )
            .getSetter( null, null );

    Element root = generateRootTestElement();

    idSetter.set( root, new Long( 123 ), getSFI() );
    textSetter.set( root, "description...", getSFI() );
    nameSetter.set( root, "JBoss", getSFI() );
    accountIdSetter.set( root, new Long( 456 ), getSFI() );

    assertTrue( "DOMs not equal", new NodeComparator().compare( DOM, root ) == 0 );
}
项目:lams    文件:DynamicMapEntityTuplizer.java   
private PropertyAccessor buildPropertyAccessor(Property mappedProperty) {
    if ( mappedProperty.isBackRef() ) {
        return mappedProperty.getPropertyAccessor(null);
    }
    else {
        return PropertyAccessorFactory.getDynamicMapPropertyAccessor();
    }
}
项目:lams    文件:DynamicMapEntityTuplizer.java   
private PropertyAccessor buildPropertyAccessor(AttributeBinding mappedProperty) {
    // TODO: fix when backrefs are working in new metamodel
    //if ( mappedProperty.isBackRef() ) {
    //  return mappedProperty.getPropertyAccessor( null );
    //}
    //else {
        return PropertyAccessorFactory.getDynamicMapPropertyAccessor();
    //}
}
项目:lams    文件:PojoEntityTuplizer.java   
private PropertyAccessor getPropertyAccessor(AttributeBinding mappedProperty) throws MappingException {
    // TODO: Fix this then backrefs are working in new metamodel
    return PropertyAccessorFactory.getPropertyAccessor(
            mappedProperty.getContainer().getClassReference(),
            mappedProperty.getPropertyAccessorName()
    );
}
项目:lams    文件:PojoComponentTuplizer.java   
public PojoComponentTuplizer(Component component) {
    super( component );

    this.componentClass = component.getComponentClass();

    String[] getterNames = new String[propertySpan];
    String[] setterNames = new String[propertySpan];
    Class[] propTypes = new Class[propertySpan];
    for ( int i = 0; i < propertySpan; i++ ) {
        getterNames[i] = getters[i].getMethodName();
        setterNames[i] = setters[i].getMethodName();
        propTypes[i] = getters[i].getReturnType();
    }

    final String parentPropertyName = component.getParentProperty();
    if ( parentPropertyName == null ) {
        parentSetter = null;
        parentGetter = null;
    }
    else {
        PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( null );
        parentSetter = pa.getSetter( componentClass, parentPropertyName );
        parentGetter = pa.getGetter( componentClass, parentPropertyName );
    }

    if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) {
        optimizer = null;
    }
    else {
        // TODO: here is why we need to make bytecode provider global :(
        // TODO : again, fix this after HHH-1907 is complete
        optimizer = Environment.getBytecodeProvider().getReflectionOptimizer(
                componentClass, getterNames, setterNames, propTypes
        );
    }
}
项目:lams    文件:PropertyFactory.java   
private static Getter getGetter(Property mappingProperty) {
    if ( mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation() ) {
        return null;
    }

    PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( mappingProperty, EntityMode.POJO );
    return pa.getGetter( mappingProperty.getPersistentClass().getMappedClass(), mappingProperty.getName() );
}
项目:lams    文件:PropertyFactory.java   
private static Getter getGetter(AttributeBinding mappingProperty) {
    if ( mappingProperty == null || mappingProperty.getContainer().getClassReference() == null ) {
        return null;
    }

    PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( mappingProperty, EntityMode.POJO );
    return pa.getGetter(
            mappingProperty.getContainer().getClassReference(),
            mappingProperty.getAttribute().getName()
    );
}
项目:cacheonix-core    文件:DynamicMapEntityTuplizer.java   
private PropertyAccessor buildPropertyAccessor(Property mappedProperty) {
    if ( mappedProperty.isBackRef() ) {
        return mappedProperty.getPropertyAccessor(null);
    }
    else {
        return PropertyAccessorFactory.getDynamicMapPropertyAccessor();
    }
}
项目:cacheonix-core    文件:Dom4jEntityTuplizer.java   
private PropertyAccessor buildPropertyAccessor(Property mappedProperty) {
    if ( mappedProperty.isBackRef() ) {
        return mappedProperty.getPropertyAccessor(null);
    }
    else {
        return PropertyAccessorFactory.getDom4jPropertyAccessor( 
                mappedProperty.getNodeName(), 
                mappedProperty.getType(),
                getEntityMetamodel().getSessionFactory()
            );
    }
}
项目:cacheonix-core    文件:PojoComponentTuplizer.java   
public PojoComponentTuplizer(Component component) {
    super( component );

    this.componentClass = component.getComponentClass();

    String[] getterNames = new String[propertySpan];
    String[] setterNames = new String[propertySpan];
    Class[] propTypes = new Class[propertySpan];
    for ( int i = 0; i < propertySpan; i++ ) {
        getterNames[i] = getters[i].getMethodName();
        setterNames[i] = setters[i].getMethodName();
        propTypes[i] = getters[i].getReturnType();
    }

    final String parentPropertyName = component.getParentProperty();
    if ( parentPropertyName == null ) {
        parentSetter = null;
        parentGetter = null;
    }
    else {
        PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( null );
        parentSetter = pa.getSetter( componentClass, parentPropertyName );
        parentGetter = pa.getGetter( componentClass, parentPropertyName );
    }

    if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) {
        optimizer = null;
    }
    else {
        // TODO: here is why we need to make bytecode provider global :(
        // TODO : again, fix this after HHH-1907 is complete
        optimizer = Environment.getBytecodeProvider().getReflectionOptimizer(
                componentClass, getterNames, setterNames, propTypes
        );
    }
}
项目:cacheonix-core    文件:PropertyFactory.java   
private static Getter getGetter(Property mappingProperty) {
    if ( mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation() ) {
        return null;
    }

    PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( mappingProperty, EntityMode.POJO );
    return pa.getGetter( mappingProperty.getPersistentClass().getMappedClass(), mappingProperty.getName() );
}
项目:cacheonix-core    文件:Dom4jAccessorTest.java   
public void testStringElementExtraction() throws Throwable {
    Property property = generateNameProperty();
    Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
            .getGetter( null, null );
    String name = ( String ) getter.get( DOM );
    assertEquals( "Not equals", "JBoss", name );
}
项目:cacheonix-core    文件:Dom4jAccessorTest.java   
public void testStringTextExtraction() throws Throwable {
    Property property = generateTextProperty();
    Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
            .getGetter( null, null );
    String name = ( String ) getter.get( DOM );
    assertEquals( "Not equals", "description...", name );
}
项目:cacheonix-core    文件:Dom4jAccessorTest.java   
public void testLongAttributeExtraction() throws Throwable {
    Property property = generateIdProperty();
    Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
            .getGetter( null, null );
    Long id = ( Long ) getter.get( DOM );
    assertEquals( "Not equals", new Long( 123 ), id );
}
项目:cacheonix-core    文件:Dom4jAccessorTest.java   
public void testLongElementAttributeExtraction() throws Throwable {
    Property property = generateAccountIdProperty();
    Getter getter = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.DOM4J )
            .getGetter( null, null );
    Long id = ( Long ) getter.get( DOM );
    assertEquals( "Not equals", new Long( 456 ), id );
}
项目:karaku    文件:KarakuAliasToBeanTransformer.java   
private void initialize(String[] newAlias) {

        PropertyAccessor propertyAccessor = new ChainedPropertyAccessor(
                new PropertyAccessor[] {
                        PropertyAccessorFactory.getPropertyAccessor(
                                resultClass, null),
                        PropertyAccessorFactory.getPropertyAccessor("field") });
        this.aliases = new String[newAlias.length];
        setters = new Setter[newAlias.length];
        for (int i = 0; i < newAlias.length; i++) {
            String alias = newAlias[i];
            if (alias != null) {
                this.aliases[i] = alias;
                // Diferencia con AliasToBeanResultTransformer

                if (alias.indexOf('.') > 0) {
                    // found nested
                    setters[i] = new NestedSetter(resultClass, alias);
                } else {

                    // -------------------------------------------
                    setters[i] = propertyAccessor.getSetter(resultClass, alias);
                    // Diferencia con AliasToBeanResultTransformer
                }
                // -------------------------------------------
            }
        }
        isInitialized = true;
    }
项目:TechnologyReadinessTool    文件:IgnoringCaseAliasToBeanResultTransformer.java   
@SuppressWarnings("rawtypes")
public IgnoringCaseAliasToBeanResultTransformer(final Class resultClass) {
    if (resultClass == null) {
        throw new IllegalArgumentException("resultClass cannot be null");
    }
    this.resultClass = resultClass;
    propertyAccessor = new ChainedPropertyAccessor(new PropertyAccessor[] {
            PropertyAccessorFactory.getPropertyAccessor(resultClass, null),
            PropertyAccessorFactory.getPropertyAccessor("field") });
    fields = this.resultClass.getDeclaredFields();
}
项目:lams    文件:Property.java   
public PropertyAccessor getPropertyAccessor(Class clazz) throws MappingException {
    return PropertyAccessorFactory.getPropertyAccessor( clazz, getPropertyAccessorName() );
}
项目:lams    文件:DynamicMapComponentTuplizer.java   
private PropertyAccessor buildPropertyAccessor(Property property) {
    return PropertyAccessorFactory.getDynamicMapPropertyAccessor();
}
项目:cacheonix-core    文件:Property.java   
public PropertyAccessor getPropertyAccessor(Class clazz) throws MappingException {
    return PropertyAccessorFactory.getPropertyAccessor( clazz, getPropertyAccessorName() );
}
项目:cacheonix-core    文件:AliasToBeanResultTransformer.java   
public AliasToBeanResultTransformer(Class resultClass) {
    if(resultClass==null) throw new IllegalArgumentException("resultClass cannot be null");
    this.resultClass = resultClass;
    propertyAccessor = new ChainedPropertyAccessor(new PropertyAccessor[] { PropertyAccessorFactory.getPropertyAccessor(resultClass,null), PropertyAccessorFactory.getPropertyAccessor("field")});      
}
项目:cacheonix-core    文件:DynamicMapComponentTuplizer.java   
private PropertyAccessor buildPropertyAccessor(Property property) {
    return PropertyAccessorFactory.getDynamicMapPropertyAccessor();
}
项目:cacheonix-core    文件:Dom4jComponentTuplizer.java   
private PropertyAccessor buildPropertyAccessor(Property property) {
    //TODO: currently we don't know a SessionFactory reference when building the Tuplizer
    //      THIS IS A BUG (embedded-xml=false on component)
    // TODO : fix this after HHH-1907 is complete
    return PropertyAccessorFactory.getDom4jPropertyAccessor( property.getNodeName(), property.getType(), null );
}