Reputation: 730
I have the following model:
class A{
Map<String, Integer> tags
}
class B{
A a;
}
I need to find instances of B where its associated A has a certain key value in its tags map
I issue the following HQL Query
FROM B WHERE index(a.tags) = 'the_value'
Unfortunately, this yields to a SQLGrammarException. The query being built has a WHERE clause that ends with:
and tags2_.tags_idx='the_value'
and the exception message is
Column not found: TAGS2_.TAGS_IDX
Unfortunately, the alias tags2_ is not previously declared in the statement, which leads to the exception.
Any ideas?
Regards
Upvotes: 0
Views: 1591
Reputation: 14061
Can you try something like this?
from B b join b.a a where index(a.tags) = 'the_value'
Or maybe:
from B b where index(b.a.tags) = 'the_value'
Upvotes: 0
Reputation: 242686
Not sure about the absent alias, but I guess you need the following syntax in this case:
FROM B WHERE 'the_value' IN INDICES(a.tags)
See also:
Upvotes: 1