我正在使用Hibernate createcriteria來連接幾個表並從數據庫中查詢數據。我發現結果返回不同於直接從SQL客戶端使用由hibernate生成的SQL語句的結果查詢。 由Hibernate返回的結果不僅僅是直接查詢。 我只是想知道爲什麼會發生?Hibernate返回結果是不同的直接查詢
下面是Hibernate個createCriteria生成的SQL語句。我用「?」取代了這個值佔位符在聲明中。
select this_.mrctBizId as mrctBizI1_5_13_, this_.name as
name11_5_13_,
from go.go_mrct_business this_
inner join go.go_location location3_ on this_.LocId=location3_.locId
inner join go.go_state state4_ on location3_.StateId=state4_.stateId
inner join go.go_country country5_ on state4_.CountryId=country5_.countryId
left outer join go.go_mrct_off_date holiday7_ on this_.mrctBizId=holiday7_.MrctBizId and ((holiday7_.startDt<='2015-05-23' and holiday7_.endDt>='2015-05-23'))
left outer join go.go_mrct_business gomrctbusi13_ on holiday7_.MrctBizId=gomrctbusi13_.mrctBizId
left outer join go.go_mrct_off_day offday6_ on this_.mrctBizId=offday6_.MrctBizId and (offday6_.offDay=7)
left outer join go.go_mrct_business gomrctbusi15_ on offday6_.MrctBizId=gomrctbusi15_.mrctBizId
inner join go.go_service service1_ on this_.mrctBizId=service1_.MrctBizId
inner join go.go_category gocategory2_ on service1_.CatId=gocategory2_.catId
left outer join go.go_mrct_business gomrctbusi20_ on service1_.MrctBizId=gomrctbusi20_.mrctBizId
where offday6_.MrctBizId is null
and holiday7_.MrctBizId is null
and this_.enabled=true
and service1_.enabled=true
and gocategory2_.catId=11
and country5_.countryId=1
and state4_.stateId=2
and location3_.locId=6
and this_.bizStartTime<=CAST('10:10:00' AS time)
and this_.bizEndTime>=CAST('10:10:00' AS time) ;
請添加更多細節,如「直接」sql查詢和條件查詢。 –
上面的SQL語句是由hibernate createCriteria生成的查詢,而且我也使用這個SQL語句直接通過SQL客戶端查詢,但都返回不同的結果 –