From: Gavin_King/Cirrus%<CI...@ci...> - 2002-07-02 00:47:43
|
> Basically, there is a parent table ("foo" in my example above) and > there is list of attributes for a particular foo object > (called "foo_attr") in my example above. I want to find all Foo's > where it have an attribute "attribute1" equal to "value1" and an > attribute "attribute2" equal to "value2". > > So, is this something I will have to implement (and if so, are there > suggestions on the syntax of the query), or does this already exist? I *think* I understand what you are trying to do though I'm not sure why you used a nested subselect so perhaps there is something I'm missing. If you were to map this as a (nested) one-to-many set of Attibutes, I think you can express this as: select foo from foo in class Foo, att1 in foo.attributes, att2 in foo.attributes where att1.name = 'attribute1' and att1.value = 'value1' and att2.name='attribute2' and att2.value = 'value2' (though the generated SQL here contains no subselects). What I would love to be able to do would be to map this instead as a (nested) map with String index + element and then express the query as: from foo in class Foo where foo.attributes['attribute1']='value1' and foo.attributes['attribute2']='value2' However, the [] indexing syntax is not implemented. The advantage of this approach is we don't have to invent this whole new class called Attribute to contain name/value pairs. If someone wants to implement [], that would be wonderful - but it might be nontrivial. Does that help? |