Skip to content

Files

Latest commit

 

History

History

HibernateSpringBootElementCollectionNoOrderColumn

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

How Regular @ElementCollection (Without @OrderColumn) Works

Description: This application reveals the possible performance penalties of using @ElementCollection. In this case, without @OrderColumn. As you can see in the next item (34) adding @OrderColumn can mitigate some performance penalties.

Key points:

  • an @ElementCollection doesn't have a primary key
  • an @ElementCollection is mapped in a separate table
  • avoid @ElementCollection when you have a lot of inserts/deletes on this collection; inserts/deletes will cause Hibernate to delete all the existing table rows, process the collection in-memory, and re-insert the remaining table rows to mirror the collection from memory
  • the more entries we have in this collection the greater the performance penalty will be

Output example:


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.