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

How to perform inner join with Jpa Query methods/JpaRepository

Junaid Akhtar
1#
Junaid Akhtar Published in 2018-02-10 05:21:35Z

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.296308 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO