join more than one table in spring jparepository

本秂侑毒 提交于 2019-12-03 17:14:23

I understand that there is separate repository for each entity(table)

This is a very common misunderstanding. You do not want to have a repository per entity, but per aggregate root. See http://static.olivergierke.de/lectures/ddd-and-spring/

Regarding your specific problem at hand: Creating a custom method in your repository interface and annotating it with a JPQL should do the trick. So you get something like:

@Query("select a from BEntity b join b.a a where b.foo = :foo")
AEntity getAllFooishAs(String foo);

You can use any join syntax JPQL offers in the query.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!