类org.hibernate.property.access.spi.PropertyAccessStrategy源码实例Demo

下面列出了怎么用org.hibernate.property.access.spi.PropertyAccessStrategy的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: mPaaS   文件: ExtendPropertyAccess.java
public ExtendPropertyAccess(PropertyAccessStrategy strategy,
		Class containerJavaType, String propertyName) {
	this.strategy = strategy;
	PropertyDescriptor desc = BeanUtils
			.getPropertyDescriptor(containerJavaType, propertyName);
	Class<?> returnType = null;
	MetaEntity entity = MetaEntity.localEntity(containerJavaType.getName());
	MetaProperty property = entity == null ? null
			: entity.getProperty(propertyName);
	if (property != null) {
		returnType = EntityUtil.getPropertyType(property.getType());
	}
	if (returnType == null) {
		returnType = Object.class;
	}
	this.getter = new DynamicPropertyGetterSetter(propertyName, returnType,
			desc == null ? null : desc.getReadMethod());
	this.setter = new DynamicPropertyGetterSetter(propertyName, returnType,
			desc == null ? null : desc.getWriteMethod());
}
 
源代码2 项目: mPaaS   文件: DynamicPropertyAccess.java
public DynamicPropertyAccess(PropertyAccessStrategy strategy,
		Class containerJavaType, String propertyName) {
	this.strategy = strategy;
	PropertyDescriptor desc = BeanUtils
			.getPropertyDescriptor(containerJavaType, propertyName);
	Class<?> returnType = null;
	MetaEntity entity = MetaEntity.localEntity(containerJavaType.getName());
	MetaProperty property = entity == null ? null
			: entity.getProperty(propertyName);
	if (property != null) {
		returnType = EntityUtil.getPropertyType(property.getType());
	}
	if (returnType == null) {
		returnType = Object.class;
	}
	this.getter = new DynamicPropertyGetterSetter(propertyName, returnType,
			desc == null ? null : desc.getReadMethod());
	this.setter = new DynamicPropertyGetterSetter(propertyName, returnType,
			desc == null ? null : desc.getWriteMethod());
}
 
源代码3 项目: ueboot   文件: FieldToBeanResultTransformer.java
private void initialize(String aliases[]) {
    PropertyAccessStrategyChainedImpl propertyAccessStrategy = new PropertyAccessStrategyChainedImpl(new PropertyAccessStrategy[]{PropertyAccessStrategyBasicImpl.INSTANCE, PropertyAccessStrategyFieldImpl.INSTANCE});
    this.aliases = new String[aliases.length];
    this.setters = new Setter[aliases.length];

    for (int i = 0; i < aliases.length; i++) {
        String alias = aliases[i];
        if (alias != null) {
            this.aliases[i] = alias;
            alias = CamelUtils.underlineToCamel(alias);
            try {
                this.setters[i] = propertyAccessStrategy.buildPropertyAccess(this.resultClass, alias).getSetter();
            } catch (Exception e) {
                this.setters[i] = null;
            }
        }
    }

    isInitialized = true;
}
 
源代码4 项目: lams   文件: Property.java
public PropertyAccessStrategy getPropertyAccessStrategy(Class clazz) throws MappingException {
	String accessName = getPropertyAccessorName();
	if ( accessName == null ) {
		if ( clazz == null || java.util.Map.class.equals( clazz ) ) {
			accessName = "map";
		}
		else {
			accessName = "property";
		}
	}

	final EntityMode entityMode = clazz == null || java.util.Map.class.equals( clazz )
			? EntityMode.MAP
			: EntityMode.POJO;

	return resolveServiceRegistry().getService( PropertyAccessStrategyResolver.class ).resolvePropertyAccessStrategy(
			clazz,
			accessName,
			entityMode
	);
}
 
@Override
public PropertyAccessStrategy resolvePropertyAccessStrategy(
		Class containerClass,
		String explicitAccessStrategyName,
		EntityMode entityMode) {

	if ( BuiltInPropertyAccessStrategies.BASIC.getExternalName().equals( explicitAccessStrategyName )
			|| BuiltInPropertyAccessStrategies.FIELD.getExternalName().equals( explicitAccessStrategyName )
			|| BuiltInPropertyAccessStrategies.MIXED.getExternalName().equals( explicitAccessStrategyName ) ) {
		if ( Managed.class.isAssignableFrom( containerClass ) ) {
			// PROPERTY (BASIC) and MIXED are not valid for bytecode enhanced entities...
			return PropertyAccessStrategyEnhancedImpl.INSTANCE;
		}
	}

	if ( StringHelper.isNotEmpty( explicitAccessStrategyName ) ) {
		return resolveExplicitlyNamedPropertyAccessStrategy( explicitAccessStrategyName );
	}

	if ( entityMode == EntityMode.MAP ) {
		return BuiltInPropertyAccessStrategies.MAP.getStrategy();
	}
	else {
		return BuiltInPropertyAccessStrategies.BASIC.getStrategy();
	}
}
 
源代码6 项目: lams   文件: PropertyFactory.java
private static Getter getGetter(Property mappingProperty) {
	if ( mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation() ) {
		return null;
	}

	final PropertyAccessStrategyResolver propertyAccessStrategyResolver =
			mappingProperty.getPersistentClass().getServiceRegistry().getService( PropertyAccessStrategyResolver.class );

	final PropertyAccessStrategy propertyAccessStrategy = propertyAccessStrategyResolver.resolvePropertyAccessStrategy(
			mappingProperty.getClass(),
			mappingProperty.getPropertyAccessorName(),
			EntityMode.POJO
	);

	final PropertyAccess propertyAccess = propertyAccessStrategy.buildPropertyAccess(
			mappingProperty.getPersistentClass().getMappedClass(),
			mappingProperty.getName()
	);

	return propertyAccess.getGetter();
}
 
源代码7 项目: lams   文件: Backref.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy(Class clazz) throws MappingException {
	if ( propertyAccessStrategy == null ) {
		propertyAccessStrategy = new PropertyAccessStrategyBackRefImpl( collectionRole, entityName );
	}
	return propertyAccessStrategy;
}
 
源代码8 项目: lams   文件: IndexBackref.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy(Class clazz) throws MappingException {
	if ( accessStrategy == null ) {
		accessStrategy = new PropertyAccessStrategyIndexBackRefImpl( collectionRole, entityName );
	}
	return accessStrategy;
}
 
源代码9 项目: lams   文件: PropertyAccessMixedImpl.java
public PropertyAccessMixedImpl(
		PropertyAccessStrategy strategy,
		Class containerJavaType,
		String propertyName) {
	this.strategy = strategy;

	AccessType propertyAccessType = getAccessType( containerJavaType, propertyName );

	switch ( propertyAccessType ) {
		case FIELD: {
			Field field = fieldOrNull( containerJavaType, propertyName );
			if ( field == null ) {
				throw new PropertyAccessBuildingException(
					"Could not locate field for property named [" + containerJavaType.getName() + "#" + propertyName + "]"
				);
			}
			this.getter = fieldGetter( containerJavaType, propertyName, field );
			this.setter = fieldSetter( containerJavaType, propertyName, field );
			break;
		}
		case PROPERTY: {
			Method getterMethod = getterMethodOrNull( containerJavaType, propertyName );
			if ( getterMethod == null ) {
				throw new PropertyAccessBuildingException(
					"Could not locate getter for property named [" + containerJavaType.getName() + "#" + propertyName + "]"
				);
			}
			Method setterMethod = setterMethodOrNull( containerJavaType, propertyName, getterMethod.getReturnType() );

			this.getter = propertyGetter( containerJavaType, propertyName, getterMethod );
			this.setter = propertySetter( containerJavaType, propertyName, setterMethod );
			break;
		}
		default: {
			throw new PropertyAccessBuildingException(
				"Invalid access type " + propertyAccessType + " for property named [" + containerJavaType.getName() + "#" + propertyName + "]"
			);
		}
	}
}
 
protected PropertyAccessStrategy resolveExplicitlyNamedPropertyAccessStrategy(String explicitAccessStrategyName) {
	final BuiltInPropertyAccessStrategies builtInStrategyEnum = BuiltInPropertyAccessStrategies.interpret(
			explicitAccessStrategyName
	);
	if ( builtInStrategyEnum != null ) {
		return builtInStrategyEnum.getStrategy();
	}

	return strategySelectorService().resolveStrategy( PropertyAccessStrategy.class, explicitAccessStrategyName );
}
 
源代码11 项目: lams   文件: PropertyAccessStrategyChainedImpl.java
@Override
public PropertyAccess buildPropertyAccess(Class containerJavaType, String propertyName) {
	for ( PropertyAccessStrategy candidate : chain ) {
		try {
			return candidate.buildPropertyAccess( containerJavaType, propertyName );
		}
		catch (Exception ignore) {
			// ignore
		}
	}

	throw new PropertyNotFoundException( "Could not resolve PropertyAccess for " + propertyName + " on " + containerJavaType );
}
 
源代码12 项目: mPaaS   文件: ExtendPropertyAccess.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
源代码13 项目: mPaaS   文件: DynamicPropertyAccess.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
源代码14 项目: lams   文件: PropertyAccessMixedImpl.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
源代码15 项目: lams   文件: PropertyAccessMapImpl.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
源代码16 项目: lams   文件: PropertyAccessFieldImpl.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
源代码18 项目: lams   文件: PropertyAccessStrategyChainedImpl.java
public PropertyAccessStrategyChainedImpl(PropertyAccessStrategy... chain) {
	this.chain = chain;
}
 
源代码19 项目: lams   文件: PropertyAccessEnhancedImpl.java
public PropertyAccessEnhancedImpl(
		PropertyAccessStrategy strategy,
		Class containerJavaType,
		String propertyName) {
	super( strategy, containerJavaType, propertyName );
}
 
源代码20 项目: lams   文件: PropertyAccessStrategyBackRefImpl.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
源代码21 项目: lams   文件: PropertyAccessStrategyNoopImpl.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return PropertyAccessStrategyNoopImpl.INSTANCE;
}
 
源代码22 项目: lams   文件: PropertyAccessEmbeddedImpl.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
源代码23 项目: lams   文件: PropertyAccessBasicImpl.java
@Override
public PropertyAccessStrategy getPropertyAccessStrategy() {
	return strategy;
}
 
 类所在包
 同包方法