Skip to main content

Auditing, Soft Deletes, Hibernate Filters and Entity Listeners

Learn Auditing, Soft Deletes, Hibernate Filters and Entity Listeners (Phase 9 · Advanced Hibernate (Advanced), Hibernate) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Entity listeners and lifecycle callbacks • JPA callbacks: @PrePersist , @PostPersist , @PreUpdate , @PostUpdate , @PreRemove , @PostRemove , @PostLoad , on the entity or in a separate listener class ( @EntityListeners ). Use for timestamps, default values, validation and simple events. • Rules: callbacks run inside the persistence context: do not call EntityManager operations or touch other entities in them; they are not triggered by bulk JPQL/native updates . Hibernate adds @CreationTimestamp / @UpdateTimestamp and @CurrentTimestamp .

More lessons in Phase 9 · Advanced Hibernate (Advanced)