HQL和SQL查询之间的不同结果

时间:2018-07-05 11:47:52

标签: sql hql h2

我遇到以下问题:我有此HQL查询:

Select b From Building b left outer join b.reservationsList r 
where :initialDate not between r.initialDate and r.finalDate and :finalDate not 
between r.initialDate and r.finalDate and b.capacity >= :people

以及H2中的以下SQL查询:

SELECT * FROM EDIFICIOS E LEFT OUTER JOIN RESERVADOS R
ON E.ID = R.BUILDING_RESERVED
WHERE '2018-07-04' NOT BETWEEN 'R.INITIAL_DATE' and 'R.FINAL_DATE'  
AND '2018-07-14' NOT BETWEEN 'R.INITIAL_DATE' and 'R.FINAL_DATE' AND E.CAPACITY >=2

由于某种原因,每个查询的结果是不同的。我需要在SQL中查询结果,但是在HQL中我没有得到结果。据我所知,这两个查询的含义相同。 有人知道有什么区别吗?为什么我得到不同的结果?

有关其他信息,这是日志:

select building0_.id as id1_1_, building0_.address as address2_1_, building0_.available as availabl3_1_, building0_.capacity as capacity4_1_,building0_.cleaning_fare as cleaning5_1_, building0_.commission as  commissi6_1_, building0_.description as descript7_1_, building0_.name as name8_1_, building0_.price as price9_1_ from edificios building0_ left outer 
join reservados reservatio1_ on building0_.id=reservatio1_.building_reserved 
where (? not between reservatio1_.initial_date and reservatio1_.final_date) and (? not between reservatio1_.initial_date and reservatio1_.final_date) and building0_.capacity>=?
2018-07-05 08:51:50.510 TRACE 9644 --- [nio-8080-exec-6]o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [DATE] - [2018-07-05]
2018-07-05 08:51:50.510 TRACE 9644 --- [nio-8080-exec-6]o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [DATE] -[2018-07-12]
2018-07-05 08:51:50.510 TRACE 9644 --- [nio-8080-exec-6]o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [INTEGER] - [1]

0 个答案:

没有答案
相关问题