@Override public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException { try { field.set(target, value); } catch (Exception e) { if(value == null && field.getType().isPrimitive()) { throw new PropertyAccessException( e, "Null value was assigned to a property of primitive type", true, clazz, name ); } else { throw new PropertyAccessException(e, "could not set a field value by reflection", true, clazz, name); } } }
public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException { try { field.set(target, value); } catch (Exception e) { if(value == null && field.getType().isPrimitive()) { throw new PropertyAccessException( e, "Null value was assigned to a property of primitive type", true, clazz, name ); } else { throw new PropertyAccessException(e, "could not set a field value by reflection", true, clazz, name); } } }
@Override public Object get(Object target) throws HibernateException { try { return field.get(target); } catch (Exception e) { throw new PropertyAccessException(e, "could not get a field value by reflection", false, clazz, name); } }
@Override public Object[] getPropertyValues(Object object) { try { return bulkAccessor.getPropertyValues( object ); } catch ( Throwable t ) { throw new PropertyAccessException( t, PROPERTY_GET_EXCEPTION, false, mappedClass, getterName( t, bulkAccessor ) ); } }
@Override public void setPropertyValues(Object object, Object[] values) { try { bulkAccessor.setPropertyValues( object, values ); } catch ( Throwable t ) { throw new PropertyAccessException( t, PROPERTY_SET_EXCEPTION, true, mappedClass, setterName( t, bulkAccessor ) ); } }
public Object get(Object target) throws HibernateException { try { return field.get(target); } catch (Exception e) { throw new PropertyAccessException(e, "could not get a field value by reflection", false, clazz, name); } }
public Object[] getPropertyValues(Object object) { try { return bulkAccessor.getPropertyValues( object ); } catch ( Throwable t ) { throw new PropertyAccessException( t, PROPERTY_GET_EXCEPTION, false, mappedClass, getterName( t, bulkAccessor ) ); } }
public void setPropertyValues(Object object, Object[] values) { try { bulkAccessor.setPropertyValues( object, values ); } catch ( Throwable t ) { throw new PropertyAccessException( t, PROPERTY_SET_EXCEPTION, true, mappedClass, setterName( t, bulkAccessor ) ); } }
public Object[] getPropertyValues(Object object) { try { return bulkBean.getPropertyValues( object ); } catch ( Throwable t ) { throw new PropertyAccessException( t, PROPERTY_GET_EXCEPTION, false, mappedClass, getterName( t, bulkBean ) ); } }
public void setPropertyValues(Object object, Object[] values) { try { bulkBean.setPropertyValues( object, values ); } catch ( Throwable t ) { throw new PropertyAccessException( t, PROPERTY_SET_EXCEPTION, true, mappedClass, setterName( t, bulkBean ) ); } }
@Override public Setter getSetter(final Class theClass, final String propertyName) throws PropertyNotFoundException { final Field field = find(OptionAwareDirectPropertyAccessor_.fieldName.andThen(equalTo(propertyName)), fields(theClass)).get(); final boolean isOption = Option.class.isAssignableFrom(field.getType()); return new Setter() { @Override public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException { try { field.setAccessible(true); field.set(target, isOption ? Option.of(value) : value); } catch (Exception e) { throw new PropertyAccessException(e, "could not set a field value by reflection", true, theClass, propertyName); } } @Override public String getMethodName() { return null; } @Override public Method getMethod() { return null; } }; }