Search in sources :

Example 1 with EnhancedSetterImpl

use of org.hibernate.property.access.spi.EnhancedSetterImpl in project hibernate-orm by hibernate.

the class PropertyAccessEnhancedImpl method resolveEnhancedSetterForField.

private static Setter resolveEnhancedSetterForField(Class<?> containerClass, String propertyName, Field field) {
    try {
        String enhancedSetterName = EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX + propertyName;
        Method enhancedSetter = containerClass.getDeclaredMethod(enhancedSetterName, field.getType());
        enhancedSetter.setAccessible(true);
        return new EnhancedSetterImpl(containerClass, propertyName, enhancedSetter);
    } catch (NoSuchMethodException e) {
        // enhancedSetter = null --- field not enhanced: fallback to reflection using the field
        return new SetterFieldImpl(containerClass, propertyName, field);
    }
}
Also used : EnhancedSetterImpl(org.hibernate.property.access.spi.EnhancedSetterImpl) Method(java.lang.reflect.Method) SetterFieldImpl(org.hibernate.property.access.spi.SetterFieldImpl)

Aggregations

Method (java.lang.reflect.Method)1 EnhancedSetterImpl (org.hibernate.property.access.spi.EnhancedSetterImpl)1 SetterFieldImpl (org.hibernate.property.access.spi.SetterFieldImpl)1