| I have a class A with a relation to a BEmbeddable. The BEmbeddable have a @PreUpdate method. When creating the entity A with B null, then load it from database (mysql). B is still null. Then I set B which created B. Then save and get the error below. Basically the problem is that we try to call the method PreUpdate on a null elemnt of B. sun.reflect.NativeMethodAccessorImpl#invoke0 In Debug:
Line 62 is `invoke0(method, obj, args)` with method = @PreUpdate method and obj is null.
@Override
public boolean performCallback(Object entity) {
try {
Object embeddable = embeddableGetter.get( entity );embeddable is null
callbackMethod.invoke( embeddable ); <-- missing at least null check here?
return true;
}
catch (InvocationTargetException e) {
if ( e.getTargetException() instanceof RuntimeException ) {
throw (RuntimeException) e.getTargetException();
}
else {
throw new RuntimeException( e.getTargetException() );
}
}
catch (Exception e) {
throw new RuntimeException( e );
}
}
Printed stack trace:
|