Skip to content

Files

Latest commit

 

History

History

HibernateSpringBootEntityListener

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Defining Entity Listener Class Via @EntityListeners

Description: This application is a sample of using the JPA @MappedSuperclass and @EntityListeners with JPA callbacks.

Key points:

  • the base class ,Book, is not an entity, it can be abstract, and is annotated with @MappedSuperclass and @EntityListeners(BookListener.class)
  • BookListener defines JPA callbacks (e.g., @PrePersist)
  • subclasses of the base class are mapped in tables that contains columns for the inherited attributes and for their own attibutes
  • when any entity that is a subclass of Book is persisted, loaded, updated, etc the corresponding JPA callbacks are called

If you need a deep dive into the performance recipes exposed in this repository then I am sure that you will love my book "Spring Boot Persistence Best Practices"If you need a hand of tips and illustrations of 100+ Java persistence performance issues then "Java Persistence Performance Illustrated Guide" is for you.