Skip to content

Latest commit

 

History

History
 
 

HibernateSpringBootDtoEntityViaProjectionNoAssociation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Entity Inside Spring Projection (no association)

If you prefer to read it as a blog-post containing the relevant snippets of code then check this post

Description: If, for some reason, you need an entity in your Spring projection (DTO), then this application shows you how to do it via an example. In this case, there are two entities, Author and Book, that have no materialized association between them, but, they share the genre attribute. We use this attribute to join authors with books via JPQL. And, we want to fetch in a Spring projection the authors as entities, Author, and the title of the books.

Key points:

  • define two unrelated entities (e.g., Author and Book)
  • define the proper Spring projection having public Author getAuthor() and public String getTitle()
  • write a JPQL to fetch data

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.