Skip to content

Instantly share code, notes, and snippets.

@tomatophobia
Last active March 22, 2024 19:05
Show Gist options
  • Save tomatophobia/9a3bea1b37c3c83c9897d68bdc51adae to your computer and use it in GitHub Desktop.
Save tomatophobia/9a3bea1b37c3c83c9897d68bdc51adae to your computer and use it in GitHub Desktop.
public static void validateProxyability(PersistentClass persistentClass) {
Iterator properties = persistentClass.getPropertyIterator();
Class clazz = persistentClass.getMappedClass();
while(properties.hasNext()) {
Property property = (Property)properties.next();
validateGetterSetterMethodProxyability("Getter", property.getGetter(clazz).getMethod());
validateGetterSetterMethodProxyability("Setter", property.getSetter(clazz).getMethod());
}
}
public static void validateGetterSetterMethodProxyability(String getterOrSetter, Method method) {
// getter/setter 존재하는데 final인지 확인
if (method != null && Modifier.isFinal(method.getModifiers())) {
throw new HibernateException(String.format("%s methods of lazy classes cannot be final: %s#%s", getterOrSetter, method.getDeclaringClass().getName(), method.getName()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment