Hi everybody
I need help with setting my HQL selection query.
I have a Map collection in my queried entity foo:
foo.bar<barKey, barValue>
Now, in my HQL i need to search specific fields of barKey with parameter and return all foo's that hold the bars that have the correct value.
So my HQL looks like this:
Code:
select f
from foo f left join f.bar b
where index(b).barKeyField = :param
But that doesn't work! I keep getting:
Quote:
3383 [main] ERROR org.hibernate.hql.PARSER - <AST>:1:519: unexpected AST node: (
java.lang.NullPointerException
at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:546)
At the beginning i thought that maybe it's because i don't alias the index(b), so even though i don't need to return it, i added it just for investigation to the select clause:
Code:
select f, index(b) as ib
from foo f left join f.bar b
where ib.barKeyField= :param
However, that didn't work too. It couldn't relate to the field under ib. It is as if it can't work with the map key at all, only the map values, which is odd.
The HQL reference demonstrates:
Quote:
HQL also provides the built-in index() function for elements of a one-to-many association or collection of values:
select item, index(item) from Order order
join order.items item
where index(item) < 5
Does this work for anyone? how can i work with the map key to search in its fields?
Thanks,
Yuval