Home How to perform inner join with Jpa Query methods/JpaRepository
Reply: 0

How to perform inner join with Jpa Query methods/JpaRepository

user741
1#
user741 Published in May 23, 2018, 8:05 pm

I would like to fetch data with one-to-many relation with inner join only.I can easily achieve the above using written direct HQL like this:

@Query("select distinct b from Batch b inner join fetch b.transactions")

But i dont want to write query as i am using JpaRepository interface which gives us very useful feature of Query By Method.

I also tried this.

    @EntityGraph(attributePaths = { "transactions" } )
    List<Batch> findDistinctByIdNotNull();

This avoids N+1 problem but performs left outer join between batch & transaction entity. Can any one help how to perform inner join with using Query method feature??

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.316757 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO