Spring Data Jpa 使用Left Join

准备:

Spring Boot + Web + Jpa

代码:

类:AccountRepository

@Query(value = "select new com.sino.report.entity.Test(a.id,a.userName) from Account a LEFT Join Hospital h on a.id = h.id")
    List<Test> findTest2();

运行项目直接出错

Path expected for join!

参考了它才知道问题所在:https://www.cnblogs.com/icebutterfly/p/9515897.html 

必须要在进行关联的表中做关系映射。

原文地址:https://www.cnblogs.com/icebutterfly/p/9515967.html