persistence icon indicating copy to clipboard operation
persistence copied to clipboard

entity listener with multiple @PrePersist (for example) methods

Open gavinking opened this issue 1 year ago • 1 comments

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.

gavinking avatar Nov 23 '24 15:11 gavinking

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.

gavinking avatar Nov 23 '24 15:11 gavinking