我有一个班级InvitedTech
。
public class InvitedTech{
...
@OneToOne(mappedBy="invitedTech", cascade = CascadeType.ALL, fetch=FetchType.LAZY)
public Flight flight;
@OneToOne(mappedBy="invitedTech", cascade = CascadeType.ALL, fetch=FetchType.LAZY)
public Hotel hotel;
...
}
当我像这样向这个表写一个查询......
List<InvitedTech> invT = JPA.em().createQuery("SELECT inv from InvitedTech inv").getResultList();
我为inviteTech表中的每一行执行了多个select语句。 因此,例如,我有11行,并在运行一个查询之后...
13:09:26,350 DEBUG ~ select invitedtec0_.id as id184_, invitedtec0_.comments as comments184_, invitedtec0_.confirmedBy as confirm11_184_, invitedtec0_.confirmedDate as confirme3_184_, invitedtec0_.contractor as contractor184_, invitedtec0_.flightNeeded as flightNe4_184_, invitedtec0_.hotelNeeded as hotelNee5_184_, invitedtec0_.inviteDate as inviteDate184_, invitedtec0_.method as method184_, invitedtec0_.payRate as payRate184_, invitedtec0_.paymentItem_id as payment13_184_, invitedtec0_.replyDate as replyDate184_, invitedtec0_.status as status184_, invitedtec0_.techRequirement as techReq14_184_ from InvitedTech invitedtec0_
13:09:26,354 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,355 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,357 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,357 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,358 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,359 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,360 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,361 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,362 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,362 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,363 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,364 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,364 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,365 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,366 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,367 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,367 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,368 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,370 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,371 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
13:09:26,372 DEBUG ~ select flight0_.id as id156_1_, flight0_.airline as airline156_1_, flight0_.confirmationNumber as confirma3_156_1_, flight0_.departure as departure156_1_, flight0_.flightNumber as flightNu5_156_1_, flight0_.invitedTechId as invitedT7_156_1_, flight0_.terminal as terminal156_1_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_ from Flight flight0_ inner join InvitedTech invitedtec1_ on flight0_.invitedTechId=invitedtec1_.id where flight0_.invitedTechId=?
13:09:26,372 DEBUG ~ select hotel0_.id as id189_2_, hotel0_.address as address189_2_, hotel0_.checkinTime as checkinT3_189_2_, hotel0_.confirmationNumber as confirma4_189_2_, hotel0_.invitedTechId as invitedT7_189_2_, hotel0_.name as name189_2_, hotel0_.phone as phone189_2_, invitedtec1_.id as id184_0_, invitedtec1_.comments as comments184_0_, invitedtec1_.confirmedBy as confirm11_184_0_, invitedtec1_.confirmedDate as confirme3_184_0_, invitedtec1_.contractor as contractor184_0_, invitedtec1_.flightNeeded as flightNe4_184_0_, invitedtec1_.hotelNeeded as hotelNee5_184_0_, invitedtec1_.inviteDate as inviteDate184_0_, invitedtec1_.method as method184_0_, invitedtec1_.payRate as payRate184_0_, invitedtec1_.paymentItem_id as payment13_184_0_, invitedtec1_.replyDate as replyDate184_0_, invitedtec1_.status as status184_0_, invitedtec1_.techRequirement as techReq14_184_0_, flight2_.id as id156_1_, flight2_.airline as airline156_1_, flight2_.confirmationNumber as confirma3_156_1_, flight2_.departure as departure156_1_, flight2_.flightNumber as flightNu5_156_1_, flight2_.invitedTechId as invitedT7_156_1_, flight2_.terminal as terminal156_1_ from Hotel hotel0_ inner join InvitedTech invitedtec1_ on hotel0_.invitedTechId=invitedtec1_.id left outer join Flight flight2_ on invitedtec1_.id=flight2_.invitedTechId where hotel0_.invitedTechId=?
我该如何解决这个问题?如果我编写自己的SQL,我可以使用in
关键字在一个语句中执行此操作。我尝试了@BatchSize(size = 20)
之类的不同内容,以便一次获取20条记录,我尝试使用@Fetch(FetchMode.JOIN)
,但所有尝试都没有效果。有没有我可以改变所以只有1个查询被执行?
如果我从删除其他查询的注释中删除mappedBy,但后来我无法访问这些属性,因为对象不知道该关系。
答案 0 :(得分:0)
要避免n + 1问题,您可以尝试使用JOIN FETCH
这样的查询(未经测试):
SELECT inv from InvitedTech inv LEFT JOIN FETCH inv.flight LEFT JOIN FETCH inv.hotel
答案 1 :(得分:0)
如果您希望查询在所有执行的查询中获取这些关系,则可以在@JoinFetch
和@BatchFetch
对象上使用flight
或hotel
注释。
或者,您可以使用查询提示来基于每个查询获取这些关系。
所有这些的例子是in this blog post。