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

项目:lams    文件:DynamicMapEntityTuplizer.java   
@Override
   protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) {

    ProxyFactory pf = new MapProxyFactory();
    try {
        //TODO: design new lifecycle for ProxyFactory
        pf.postInstantiate(
                getEntityName(),
                null,
                null,
                null,
                null,
                null
        );
    }
    catch ( HibernateException he ) {
        LOG.unableToCreateProxyFactory( getEntityName(), he );
        pf = null;
    }
    return pf;
}
项目:lams    文件:DynamicMapEntityTuplizer.java   
@Override
protected ProxyFactory buildProxyFactory(EntityBinding mappingInfo, Getter idGetter, Setter idSetter) {

    ProxyFactory pf = new MapProxyFactory();
    try {
        //TODO: design new lifecycle for ProxyFactory
        pf.postInstantiate(
                getEntityName(),
                null,
                null,
                null,
                null,
                null
        );
    }
    catch ( HibernateException he ) {
        LOG.unableToCreateProxyFactory(getEntityName(), he);
        pf = null;
    }
    return pf;
}
项目:lams    文件:AbstractComponentTuplizer.java   
protected AbstractComponentTuplizer(Component component) {
    propertySpan = component.getPropertySpan();
    getters = new Getter[propertySpan];
    setters = new Setter[propertySpan];

    Iterator iter = component.getPropertyIterator();
    boolean foundCustomAccessor=false;
    int i = 0;
    while ( iter.hasNext() ) {
        Property prop = ( Property ) iter.next();
        getters[i] = buildGetter( component, prop );
        setters[i] = buildSetter( component, prop );
        if ( !prop.isBasicPropertyAccessor() ) {
            foundCustomAccessor = true;
        }
        i++;
    }
    hasCustomAccessors = foundCustomAccessor;
    instantiator = buildInstantiator( component );
}
项目:lams    文件:AbstractQueryImpl.java   
public Query setProperties(Object bean) throws HibernateException {
    Class clazz = bean.getClass();
    String[] params = getNamedParameters();
    for (int i = 0; i < params.length; i++) {
        String namedParam = params[i];
        try {
            Getter getter = ReflectHelper.getGetter( clazz, namedParam );
            Class retType = getter.getReturnType();
            final Object object = getter.get( bean );
            if ( Collection.class.isAssignableFrom( retType ) ) {
                setParameterList( namedParam, ( Collection ) object );
            }
            else if ( retType.isArray() ) {
                setParameterList( namedParam, ( Object[] ) object );
            }
            else {
                setParameter( namedParam, object, determineType( namedParam, retType ) );
            }
        }
        catch (PropertyNotFoundException pnfe) {
            // ignore
        }
    }
    return this;
}
项目:cacheonix-core    文件:DynamicMapEntityTuplizer.java   
protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) {

        ProxyFactory pf = new MapProxyFactory();
        try {
            //TODO: design new lifecycle for ProxyFactory
            pf.postInstantiate(
                    getEntityName(),
                    null,
                    null,
                    null,
                    null,
                    null
            );
        }
        catch ( HibernateException he ) {
            log.warn( "could not create proxy factory for:" + getEntityName(), he );
            pf = null;
        }
        return pf;
    }
项目:cacheonix-core    文件:Dom4jEntityTuplizer.java   
protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) {
    HashSet proxyInterfaces = new HashSet();
    proxyInterfaces.add( HibernateProxy.class );
    proxyInterfaces.add( Element.class );

    ProxyFactory pf = new Dom4jProxyFactory();
    try {
        pf.postInstantiate(
                getEntityName(),
                Element.class,
                proxyInterfaces,
                null,
                null,
                mappingInfo.hasEmbeddedIdentifier() ?
                        (AbstractComponentType) mappingInfo.getIdentifier().getType() :
                        null
        );
    }
    catch ( HibernateException he ) {
        log.warn( "could not create proxy factory for:" + getEntityName(), he );
        pf = null;
    }
    return pf;
}
项目:cacheonix-core    文件:AbstractQueryImpl.java   
public Query setProperties(Object bean) throws HibernateException {
    Class clazz = bean.getClass();
    String[] params = getNamedParameters();
    for (int i = 0; i < params.length; i++) {
        String namedParam = params[i];
        try {
            Getter getter = ReflectHelper.getGetter( clazz, namedParam );
            Class retType = getter.getReturnType();
            final Object object = getter.get( bean );
            if ( Collection.class.isAssignableFrom( retType ) ) {
                setParameterList( namedParam, ( Collection ) object );
            }
            else if ( retType.isArray() ) {
                setParameterList( namedParam, ( Object[] ) object );
            }
            else {
                setParameter( namedParam, object, determineType( namedParam, retType ) );
            }
        }
        catch (PropertyNotFoundException pnfe) {
            // ignore
        }
    }
    return this;
}
项目:lams    文件:AbstractEntityTuplizer.java   
@Override
public Getter getVersionGetter() {
    if ( getEntityMetamodel().isVersioned() ) {
        return getGetter( getEntityMetamodel().getVersionPropertyIndex() );
    }
    return null;
}
项目: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()
    );
}
项目:lams    文件:UnsavedValueFactory.java   
/**
 * Return an IdentifierValue for the specified unsaved-value. If none is specified,
 * guess the unsaved value by instantiating a test instance of the class and
 * reading it's version property value, or if that is not possible, using the java default
 * value for the type
 *
 * @param versionUnsavedValue The mapping defined unsaved value
 * @param versionGetter The version attribute getter
 * @param versionType The mapping type for the version
 * @param constructor The constructor for the entity
 *
 * @return The appropriate VersionValue
 */
public static VersionValue getUnsavedVersionValue(
        String versionUnsavedValue, 
        Getter versionGetter,
        VersionType versionType,
        Constructor constructor) {

    if ( versionUnsavedValue == null ) {
        if ( constructor!=null ) {
            final Object defaultValue = versionGetter.get( instantiate( constructor ) );
            // if the version of a newly instantiated object is not the same
            // as the version seed value, use that as the unsaved-value
            return versionType.isEqual( versionType.seed( null ), defaultValue )
                    ? VersionValue.UNDEFINED
                    : new VersionValue( defaultValue );
        }
        else {
            return VersionValue.UNDEFINED;
        }
    }
    else if ( "undefined".equals( versionUnsavedValue ) ) {
        return VersionValue.UNDEFINED;
    }
    else if ( "null".equals( versionUnsavedValue ) ) {
        return VersionValue.NULL;
    }
    else if ( "negative".equals( versionUnsavedValue ) ) {
        return VersionValue.NEGATIVE;
    }
    else {
        // this should not happen since the DTD prevents it
        throw new MappingException( "Could not parse version unsaved-value: " + versionUnsavedValue );
    }
}
项目:lams    文件:ReflectHelper.java   
private static Getter getter(Class clazz, String name) throws MappingException {
    try {
        return BASIC_PROPERTY_ACCESSOR.getGetter( clazz, name );
    }
    catch ( PropertyNotFoundException pnfe ) {
        return DIRECT_PROPERTY_ACCESSOR.getGetter( clazz, name );
    }
}
项目:openbravo-brazil    文件:OBDynamicTuplizer.java   
@Override
protected ProxyFactory buildProxyFactory(PersistentClass thePersistentClass, Getter idGetter,
    Setter idSetter) {
  ProxyFactory pf = new MapProxyFactory();
  try {
    pf.postInstantiate(getEntityName(), null, null, null, null, null);
  } catch (final HibernateException he) {
    log.warn("could not create proxy factory for:" + getEntityName(), he);
    pf = null;
  }
  return pf;
}
项目:cacheonix-core    文件:AbstractComponentTuplizer.java   
protected AbstractComponentTuplizer(Component component) {
    propertySpan = component.getPropertySpan();
    getters = new Getter[propertySpan];
    setters = new Setter[propertySpan];

    Iterator iter = component.getPropertyIterator();
    boolean foundCustomAccessor=false;
    int i = 0;
    while ( iter.hasNext() ) {
        Property prop = ( Property ) iter.next();
        getters[i] = buildGetter( component, prop );
        setters[i] = buildSetter( component, prop );
        if ( !prop.isBasicPropertyAccessor() ) {
            foundCustomAccessor = true;
        }
        i++;
    }
    hasCustomAccessors = foundCustomAccessor;

    String[] getterNames = new String[propertySpan];
    String[] setterNames = new String[propertySpan];
    Class[] propTypes = new Class[propertySpan];
    for ( int j = 0; j < propertySpan; j++ ) {
        getterNames[j] = getters[j].getMethodName();
        setterNames[j] = setters[j].getMethodName();
        propTypes[j] = getters[j].getReturnType();
    }
    instantiator = buildInstantiator( component );
}
项目: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    文件:UnsavedValueFactory.java   
public static VersionValue getUnsavedVersionValue(
        String versionUnsavedValue, 
        Getter versionGetter,
        VersionType versionType,
        Constructor constructor) {

    if ( versionUnsavedValue == null ) {
        if ( constructor!=null ) {
            Object defaultValue = versionGetter.get( instantiate(constructor) );
            // if the version of a newly instantiated object is not the same
            // as the version seed value, use that as the unsaved-value
            return versionType.isEqual( versionType.seed( null ), defaultValue ) ?
                    VersionValue.UNDEFINED :
                    new VersionValue( defaultValue );
        }
        else {
            return VersionValue.UNDEFINED;
        }
    }
    else if ( "undefined".equals( versionUnsavedValue ) ) {
        return VersionValue.UNDEFINED;
    }
    else if ( "null".equals( versionUnsavedValue ) ) {
        return VersionValue.NULL;
    }
    else if ( "negative".equals( versionUnsavedValue ) ) {
        return VersionValue.NEGATIVE;
    }
    else {
        // this should not happen since the DTD prevents it
        throw new MappingException( "Could not parse version unsaved-value: " + versionUnsavedValue );
    }

}
项目:cacheonix-core    文件:ReflectHelper.java   
private static Getter getter(Class clazz, String name) throws MappingException {
    try {
        return BASIC_PROPERTY_ACCESSOR.getGetter(clazz, name);
    }
    catch (PropertyNotFoundException pnfe) {
        return DIRECT_PROPERTY_ACCESSOR.getGetter(clazz, name);
    }
}
项目:cacheonix-core    文件:MyEntityTuplizer.java   
protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) {
    // allows defining a custom proxy factory, which is responsible for
    // generating lazy proxies for a given entity.
    //
    // Here we simply use the default...
    return super.buildProxyFactory( persistentClass, idGetter, idSetter );
}
项目: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 );
}
项目:Lucee4    文件:AbstractEntityTuplizerImpl.java   
@Override
protected ProxyFactory buildProxyFactory(PersistentClass pc, Getter arg1,Setter arg2) {
    CFCHibernateProxyFactory pf = new CFCHibernateProxyFactory();
    pf.postInstantiate(pc);

    return pf;
}
项目:spring-dynamic    文件:ReflectHelper.java   
private static Getter getter(Class clazz, String name) throws MappingException {
    try {
        return BASIC_PROPERTY_ACCESSOR.getGetter( clazz, name );
    }
    catch ( PropertyNotFoundException pnfe ) {
        return DIRECT_PROPERTY_ACCESSOR.getGetter( clazz, name );
    }
}
项目:jspresso-ce    文件:DynamicPojoEntityTuplizer.java   
/**
 * {@inheritDoc}
 */
@Override
protected ProxyFactory buildProxyFactory(PersistentClass persistentClass,
    Getter idGetter, Setter idSetter) {
  fixPropertyAccessors(persistentClass);
  return super.buildProxyFactory(persistentClass, idGetter, idSetter);
}
项目:jspresso-ce    文件:DynamicPojoEntityTuplizer.java   
/**
 * {@inheritDoc}
 */
@Override
protected Getter buildPropertyGetter(Property mappedProperty,
    PersistentClass mappedEntity) {
  return new EntityPropertyAccessor().getGetter(
      mappedEntity.getMappedClass(), mappedProperty.getName());
}
项目:query-utils    文件:OptionAwarePojoEntityTuplizer.java   
@Override
protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) {
    if (!"property".equals(mappedProperty.getPropertyAccessorName())) {
        mappedProperty.setPropertyAccessorName(OptionAwareDirectPropertyAccessor.class.getName());
    }
    return super.buildPropertyGetter(mappedProperty, mappedEntity);
}
项目:lams    文件:Property.java   
public Getter getGetter(Class clazz) throws PropertyNotFoundException, MappingException {
    return getPropertyAccessor(clazz).getGetter( clazz, name );
}
项目:lams    文件:AbstractEntityTuplizer.java   
@Override
public Getter getIdentifierGetter() {
    return idGetter;
}
项目:lams    文件:AbstractEntityTuplizer.java   
@Override
public Getter getGetter(int i) {
    return getters[i];
}
项目:lams    文件:DynamicMapEntityTuplizer.java   
@Override
   protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) {
    return buildPropertyAccessor(mappedProperty).getGetter( null, mappedProperty.getName() );
}
项目:lams    文件:DynamicMapEntityTuplizer.java   
@Override
protected Getter buildPropertyGetter(AttributeBinding mappedProperty) {
    return buildPropertyAccessor( mappedProperty ).getGetter( null, mappedProperty.getAttribute().getName() );
}
项目:lams    文件:PojoEntityTuplizer.java   
protected ProxyFactory buildProxyFactoryInternal(PersistentClass persistentClass, Getter idGetter, Setter idSetter) {
        // TODO : YUCK!!!  fix after HHH-1907 is complete
        return Environment.getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory();
//      return getFactory().getSettings().getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory();
    }
项目:lams    文件:PojoEntityTuplizer.java   
@Override
protected ProxyFactory buildProxyFactory(EntityBinding entityBinding, Getter idGetter, Setter idSetter) {
    // determine the id getter and setter methods from the proxy interface (if any)
    // determine all interfaces needed by the resulting proxy
    HashSet<Class> proxyInterfaces = new HashSet<Class>();
    proxyInterfaces.add( HibernateProxy.class );

    Class mappedClass = entityBinding.getEntity().getClassReference();
    Class proxyInterface = entityBinding.getProxyInterfaceType().getValue();

    if ( proxyInterface!=null && !mappedClass.equals( proxyInterface ) ) {
        if ( ! proxyInterface.isInterface() ) {
            throw new MappingException(
                    "proxy must be either an interface, or the class itself: " + getEntityName()
            );
        }
        proxyInterfaces.add( proxyInterface );
    }

    if ( mappedClass.isInterface() ) {
        proxyInterfaces.add( mappedClass );
    }

    for ( EntityBinding subEntityBinding : entityBinding.getPostOrderSubEntityBindingClosure() ) {
        final Class subclassProxy = subEntityBinding.getProxyInterfaceType().getValue();
        final Class subclassClass = subEntityBinding.getClassReference();
        if ( subclassProxy!=null && !subclassClass.equals( subclassProxy ) ) {
            if ( ! subclassProxy.isInterface() ) {
                throw new MappingException(
                        "proxy must be either an interface, or the class itself: " + subEntityBinding.getEntity().getName()
                );
            }
            proxyInterfaces.add( subclassProxy );
        }
    }

    for ( AttributeBinding property : entityBinding.attributeBindings() ) {
        Method method = getGetter( property ).getMethod();
        if ( method != null && Modifier.isFinal( method.getModifiers() ) ) {
            LOG.gettersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName());
        }
        method = getSetter( property ).getMethod();
        if ( method != null && Modifier.isFinal( method.getModifiers() ) ) {
            LOG.settersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName());
        }
    }

    Method idGetterMethod = idGetter==null ? null : idGetter.getMethod();
    Method idSetterMethod = idSetter==null ? null : idSetter.getMethod();

    Method proxyGetIdentifierMethod = idGetterMethod==null || proxyInterface==null ?
            null :
            ReflectHelper.getMethod(proxyInterface, idGetterMethod);
    Method proxySetIdentifierMethod = idSetterMethod==null || proxyInterface==null  ?
            null :
            ReflectHelper.getMethod(proxyInterface, idSetterMethod);

    ProxyFactory pf = buildProxyFactoryInternal( entityBinding, idGetter, idSetter );
    try {
        pf.postInstantiate(
                getEntityName(),
                mappedClass,
                proxyInterfaces,
                proxyGetIdentifierMethod,
                proxySetIdentifierMethod,
                entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded()
                        ? ( CompositeType ) entityBinding
                                .getHierarchyDetails()
                                .getEntityIdentifier()
                                .getValueBinding()
                                .getHibernateTypeDescriptor()
                                .getResolvedTypeMapping()
                        : null
        );
    }
    catch ( HibernateException he ) {
        LOG.unableToCreateProxyFactory(getEntityName(), he);
        pf = null;
    }
    return pf;
}
项目:lams    文件:PojoEntityTuplizer.java   
protected ProxyFactory buildProxyFactoryInternal(EntityBinding entityBinding, Getter idGetter, Setter idSetter) {
        // TODO : YUCK!!!  fix after HHH-1907 is complete
        return Environment.getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory();
//      return getFactory().getSettings().getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory();
    }
项目:lams    文件:PojoEntityTuplizer.java   
@Override
   protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) {
    return mappedProperty.getGetter( mappedEntity.getMappedClass() );
}
项目:lams    文件:PojoEntityTuplizer.java   
@Override
protected Getter buildPropertyGetter(AttributeBinding mappedProperty) {
    return getGetter( mappedProperty );
}
项目:lams    文件:PojoEntityTuplizer.java   
private Getter getGetter(AttributeBinding mappedProperty)  throws PropertyNotFoundException, MappingException {
    return getPropertyAccessor( mappedProperty ).getGetter(
            mappedProperty.getContainer().getClassReference(),
            mappedProperty.getAttribute().getName()
    );
}
项目:lams    文件:AbstractComponentTuplizer.java   
public Getter getGetter(int i) {
    return getters[i];
}
项目:lams    文件:PojoComponentTuplizer.java   
protected Getter buildGetter(Component component, Property prop) {
    return prop.getGetter( component.getComponentClass() );
}