use of org.hibernate.PropertyNotFoundException in project hibernate-orm by hibernate.
the class ReflectHelper method findGetterMethod.
public static Method findGetterMethod(Class containerClass, String propertyName) {
Class checkClass = containerClass;
Method getter = null;
// check containerClass, and then its super types (if any)
while (getter == null && checkClass != null) {
if (checkClass.equals(Object.class)) {
break;
}
getter = getGetterOrNull(checkClass, propertyName);
checkClass = checkClass.getSuperclass();
}
// if no getter found yet, check all implemented interfaces
if (getter == null) {
getter = getGetterOrNull(containerClass.getInterfaces(), propertyName);
}
if (getter == null) {
throw new PropertyNotFoundException(String.format(Locale.ROOT, "Could not locate getter method for property [%s#%s]", containerClass.getName(), propertyName));
}
getter.setAccessible(true);
return getter;
}
use of org.hibernate.PropertyNotFoundException in project hibernate-orm by hibernate.
the class ReflectHelper method findSetterMethod.
public static Method findSetterMethod(Class containerClass, String propertyName, Class propertyType) {
Class checkClass = containerClass;
Method setter = null;
// check containerClass, and then its super types (if any)
while (setter == null && checkClass != null) {
if (checkClass.equals(Object.class)) {
break;
}
setter = setterOrNull(checkClass, propertyName, propertyType);
checkClass = checkClass.getSuperclass();
}
// if no setter found yet, check all implemented interfaces
if (setter == null) {
setter = setterOrNull(containerClass.getInterfaces(), propertyName, propertyType);
// for ( Class theInterface : containerClass.getInterfaces() ) {
// setter = setterOrNull( theInterface, propertyName, propertyType );
// if ( setter != null ) {
// break;
// }
// }
}
if (setter == null) {
throw new PropertyNotFoundException(String.format(Locale.ROOT, "Could not locate setter method for property [%s#%s]", containerClass.getName(), propertyName));
}
setter.setAccessible(true);
return setter;
}
Aggregations