I have two entities Outlet and Report.They are not connected in Entity class. I want Reports even when outlet id is not present. Following is the query I am writing but its behaving like inner join.
@Query("Select rep,out.area.area_name from Report rep left join Outlet out on out.id=rep.outletId where rep.cDate in :dates")
List<Object[]> getReportsByMethodAndFormulaAndTimePeriods(@Param("dates") List<LocalDate> dates);
Any ideas?
It is not SQL so join happens by entities fields. The query should be like this
@Query("Select rep,out.area.area_name from Report rep left join rep.outlet out where rep.cDate in :dates")
I assume the Report entity has a nullable field Outlet outlet.
Also in your case the out.area.area_name
could fail if there is no related outlet
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.