Dialect:
PostgreSQL
Version: H3b4
We have filtering working nicely (great feature guys!!) but have just noticed a problem with subselects.
Below is a simple HQL query involving one class, one parameter and a subselect. The class is called "BaseDeal" and has a filter applied.
Code:
select bd from BaseDeal bd
where bd.product.id = :id
and bd.grossPrice =
( select min(bd2.grossPrice) from BaseDeal bd2 where bd2.product.id = bd.product.id )
The query fails since the filter seems to apply the filter parameter (which is a timestamp) in the productId position (which is an integer).
The generated SQL:
Code:
from BaseDeal basedeal0_
where ? >= basedeal0_.effFrom and ? < basedeal0_.effTo
and ((basedeal0_.productId=? ))
The query fails using either positional or named parameters.
If you just remove the parameter and add it by String concatenation the query works fine.The generated SQL:
Code:
from BaseDeal basedeal1_
where ? >= basedeal1_.effFrom and ? < basedeal1_.effTo
and ((basedeal1_.productId=basedeal0_.productId )))))
The mapping file:
Code:
<class name="BaseDeal" table="BaseDeal">
...
<filter name="effectiveDateFilter" condition=":asOfDate >= effFrom and :asOfDate < effTo "/>
</class>
<filter-def name="effectiveDateFilter">
<filter-param name="asOfDate" type="timestamp"/>
</filter-def>
Is this a known "feature" with subselects for filtered classes or have I missed a FAQ entry somewhere? Perhaps this is not supported yet...
Thanks,
Ben