-------------------DOMAIN CLASSES-------------------- class Venture{ static hasMany = [executives:Role,advisors:Role, team:Role]}
class Role{ Person owner } --------------------Goal Trying to Obtain----------------------- Return all Venture instances where the Person "userId" has a designated Role
---------------------The Query-------------------------- select venture from Venture venture inner join venture.executives as ex inner join venture.advisors as av inner join venture.team as tm where :userId in elements(ex.owner) or :personInstance in elements(av.owner) or :personInstance in elements(tm.owner)
-----------------------HQL Exception I get------------------------- Message: unexpected token: exists near line 6, column 23 [ select venture from TEC.Venture venture inner join venture.executives as ex inner join venture.advisors as av inner join venture.team as tm where :userId exists elements(ex.owner) or :userId exists elements(av.owner) or :userId exists elements(tm.owner) ]
------------------------Solution so far----------------------- I solved this problem by performing separate queries than joining the results.....However, if there's any feedback you can offer regarding how to join multiple associations and filter based upon the ids of a child attribute within the association it will be greatly helpful!
|