【发布时间】:2015-08-04 08:46:09
【问题描述】:
我正在使用 Hibernate createcriteria 来连接几个表并从数据库中查询数据。我发现结果返回与直接从 SQL 客户端使用 hibernate 生成的 SQL 语句查询的结果不同。 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客户端查询,但是返回的结果不同
标签: hibernate