Assume the following code snippet that uses @PrePersist and @PreUpdate annotations and inherited inheritance:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class A {
...
@PrePersist
private void prePersist() {
...
}
@PreUpdate
private void preUpdate() {
...
}
}
@Entity
@DiscriminatorValue("B")
public class B extends A {
...
@PrePersist
private void prePersist() {
...
}
@PreUpdate
private void preUpdate() {
...
}
}
Question: Can we rely on any order of execution of callback methods?
For example, if persisting classes A and B use the prePersist method in B before the prePersist method in or vice versa?
Is it possible to assume that prePersist in B will be executed before class A is saved?
Aliuk source
share