I'm designing database and entities. I need to define shared lifecycle actions for some entities.
Can I annotate @EntityListeners
on interfaces so that entities implementing the interface affects?
@EntityListeners({StorageObjectOwnerListener.class})
public interface StorageObjectOwner {
}
public class StorageOwnerOwnerListener {
@PreRemove
private void onPreRemove(final Object object) {
}
}
Now any entity implements get affected.
public class MyEntity implements StorageObjectOwner {
// will StorageObjectOwnerListener take action?
}