org.hibernate.property.access.spi.PropertyAccessStrategy Java Examples
The following examples show how to use
org.hibernate.property.access.spi.PropertyAccessStrategy.
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: PropertyFactory.java From lams with GNU General Public License v2.0 | 6 votes |
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(); }
Example #2
Source File: DynamicPropertyAccess.java From mPaaS with Apache License 2.0 | 6 votes |
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()); }
Example #3
Source File: FieldToBeanResultTransformer.java From ueboot with BSD 3-Clause "New" or "Revised" License | 6 votes |
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; }
Example #4
Source File: PropertyAccessStrategyResolverStandardImpl.java From lams with GNU General Public License v2.0 | 6 votes |
@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(); } }
Example #5
Source File: ExtendPropertyAccess.java From mPaaS with Apache License 2.0 | 6 votes |
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()); }
Example #6
Source File: Property.java From lams with GNU General Public License v2.0 | 6 votes |
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 ); }
Example #7
Source File: PropertyAccessStrategyChainedImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@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 ); }
Example #8
Source File: PropertyAccessStrategyResolverStandardImpl.java From lams with GNU General Public License v2.0 | 5 votes |
protected PropertyAccessStrategy resolveExplicitlyNamedPropertyAccessStrategy(String explicitAccessStrategyName) { final BuiltInPropertyAccessStrategies builtInStrategyEnum = BuiltInPropertyAccessStrategies.interpret( explicitAccessStrategyName ); if ( builtInStrategyEnum != null ) { return builtInStrategyEnum.getStrategy(); } return strategySelectorService().resolveStrategy( PropertyAccessStrategy.class, explicitAccessStrategyName ); }
Example #9
Source File: PropertyAccessMixedImpl.java From lams with GNU General Public License v2.0 | 5 votes |
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 + "]" ); } } }
Example #10
Source File: IndexBackref.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy(Class clazz) throws MappingException { if ( accessStrategy == null ) { accessStrategy = new PropertyAccessStrategyIndexBackRefImpl( collectionRole, entityName ); } return accessStrategy; }
Example #11
Source File: Backref.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy(Class clazz) throws MappingException { if ( propertyAccessStrategy == null ) { propertyAccessStrategy = new PropertyAccessStrategyBackRefImpl( collectionRole, entityName ); } return propertyAccessStrategy; }
Example #12
Source File: PropertyAccessEmbeddedImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }
Example #13
Source File: PropertyAccessStrategyNoopImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return PropertyAccessStrategyNoopImpl.INSTANCE; }
Example #14
Source File: PropertyAccessBasicImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }
Example #15
Source File: PropertyAccessStrategyBackRefImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }
Example #16
Source File: PropertyAccessEnhancedImpl.java From lams with GNU General Public License v2.0 | 4 votes |
public PropertyAccessEnhancedImpl( PropertyAccessStrategy strategy, Class containerJavaType, String propertyName) { super( strategy, containerJavaType, propertyName ); }
Example #17
Source File: PropertyAccessFieldImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }
Example #18
Source File: PropertyAccessStrategyChainedImpl.java From lams with GNU General Public License v2.0 | 4 votes |
public PropertyAccessStrategyChainedImpl(PropertyAccessStrategy... chain) { this.chain = chain; }
Example #19
Source File: PropertyAccessStrategyIndexBackRefImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }
Example #20
Source File: PropertyAccessMapImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }
Example #21
Source File: PropertyAccessMixedImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }
Example #22
Source File: DynamicPropertyAccess.java From mPaaS with Apache License 2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }
Example #23
Source File: ExtendPropertyAccess.java From mPaaS with Apache License 2.0 | 4 votes |
@Override public PropertyAccessStrategy getPropertyAccessStrategy() { return strategy; }