Skip to content

Files

Latest commit

 

History

History

HibernateSpringBootJustManyToOne

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

How Efficient Is Just @OManyToOne

Note: The @ManyToOne association maps exactly to the one-to-many table relationship. The underlying foreign key is under child-side control in unidirectional or bidirectional relationship.

Description: This application shows that using only @ManyToOne is quite efficient. On the other hand, using only @OneToMany is far away from being efficient. Always, prefer bidirectional @OneToMany or unidirectional @ManyToOne. Consider two entities, Author and Book in a unidirectional @ManyToOne relationship.

Key points:

  • Adding a new book is efficient
  • Fetching all books of an author is efficient via a JPQL
  • Pagination of books is efficient
  • Remove a book is efficient
  • Even if the fetched collection is not managed, dirty checking mechanism works as expected

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.