Question

I am new to HQL and have the following table relationships:

  • Term has many Definitions
  • Definition has many DefinitionProducts
  • DefinitionProducts has one Product

I want to get the list of Terms that have at least one Definition that has at least one DefinitionProduct that has a specific Product

This is my best attempt (in Grails):

Term.findAll("from Term t, Definition d inner join t.definitions def,  
def.definitionProducts dp where ? = some elements (dp.product)",
Product.get(1))

With the above, I get a "def.definitionProducts is not mapped" exception.

Was it helpful?

Solution

select t from Term t join t.definitions def join def.definitionProducts dp where dp.product=?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top