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 

 

必須要在進行關聯的表中做關系映射。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM