persistence
persistence copied to clipboard
entity listener with multiple @PrePersist (for example) methods
I can't find where we specify whether this is allowed:
class EntityListener {
@PrePersist void onPersistBook(Book book) {}
@PrePersist void onPersistAuthor(Author book) {}
}
I think it should be allowed.
Oh, wait, I did find it, buried in the section on XML:
An entity listener class can define multiple callback methods. However, at most one method of an entity listener class can be designated as a pre-persist method, post-persist method, pre-remove method, post-remove method, pre-update method, post-update method, and/or post-load method, regardless of whether the XML descriptor is used to define entity listeners or whether some combination of annotations and XML descriptor elements is used.
But I think we should change this.