Hi!
How can I query collection elements? What I mean by that is that persistent object has a property (collections) which holds other (same type) objects. I want to query those objects. I've written the query
select elements(p.Friends) as friends from Person p where friends.Name like '" + searchPattern + "'"
and this produces an error " , expected in SELECT".
What I want from this query (if it is not obvious) is to filter friends collection based on the Name property of the object. The Friends collection holds Person objects -- the same type as the "parent" object.
To iliustrate.
Say I have a persons named A, AA, AAA, and AAAA. Now, A has friends:
AAA and AAAA. And AAAA has friends AA, and AAA.
I want to write a HQL query, that would tell me which persons have a friend named like AA%. The result would return two person objects (A and AAAA).
I looked a filtering the collection, but I don't know how to apply that here, since I have many collections (elements(p.Friends)).
Thanks,
Miha
|