Springboot jpa association query

  jpa, springboot

Jpa Associates Queries Based on Cascaded Attributes

@Query("SELECT DISTINCT mag FROM Magazine mag,
    IN(mag.articles) art
    WHERE art.name= 'Grisham'")

The paging function of Page can be used normally in this way.

By name

public Page<Magazine> findDistinctByArticles_Name(Pageable page,String name);

In this way, distinct is filtered by memory, and page’s count is also inaccurate.

docs