Lifecycle Events
  • The supported lifecycle events are PrePersist, PostPersist, PreRemove, PostRemove, PreUpdate, PostUpdate, and PostLoad
  • An entity may define its own lifecycle callback methods (subclasses my override)
Callback Methods Example  
  • An entity listener may be used to monitor lifecycle events
  • Entity listeners are invoked before entity callback methods (hierarchy is observed)
Entity Listener Example  
  • Entity listeners can be "excluded" by subclasses
Listener Exclusion Example  
  @Entity
  @ExcludeDefaultListeners // Defined in XML descriptor!
  @ExcludeSuperclassListeners
  public class EntityClass extends SomeOtherEntityClass {
    ...
  }