Andrus,
This would be another advantage of having that "application based view of
data".
You would have more control over the data relationships.
-John
On 3/3/05 6:56 AM, "Robert Zeigler" <rdzeigl...arizona.edu> wrote:
> Sorry for the confusion; Josh is correct about what I want to do:
> define a filter for a relationship that I map in the modeler. =)
>
> A couple of usage examples follow, if you're interested in specific
> cases where this might be useful. =)
>
> 2 tables (table definitions truncated =):
> Form: id (int), name (varchar(32))
> ForumMesages: id(int), forumid(int), parentid(int), message (longvarchar)
>
> Now, you want to define a relationship like,
> "topLevelMessages", which is the result of a query like:
> select * from ForumMessages where forumid=? and parentid is null;
> Is it possible to create such a "filtered relationship" within the modeler?
>
> If possible, I'd like to avoid writing either of the following bits of code:
>
> public List getTopLevelMessages() {
> List messages = this.getAllMessages();//modeler-defined relationship
> return ExpressionFactory.matchExp("parent",null).filterObjects(messages);
> }
>
> or
>
> public List getTopLevelMessages() {
> //top level messages is a query defined in the modeler
> //it returns objects of type "ForumMessage".
> //it has a single parameter, forum
> String queryName="topLevelMessages";
> Map parameters = new HashMap();
> parameters.put("forum",this);
> return this.dataContext.performQuery(queryName,parameters,true);
> }
>
>
> While neither snippet is much work, they are both mindless coding and
> tedious to do if you have several such relationships. Sounds like a
> great task for the modeler and generated code. =)
> Any thoughts?
>
> Thanks again,
>
> Robert
>
>
> Joshua Pyle wrote:
>> I think he wants to be able to define that filter in the modler so the
>> DB is queried using the filter.
>>
>>
>> On Thu, 03 Mar 2005 08:40:04 +0100, Jürgen Saar <jsaa..eb.de> wrote:
>>
>>> I don't know if I have the right understanding for your problem.
>>>
>>> Do you want to set a filter for the List of objects living in a relation?
>>>
>>> cayenne-use..bjectstyle.org schrieb am 03.03.05 04:54:10:
>>>
>>>> Is it possible to define a query which is then used
>>>> as the basis for an attribute or relationship of an object?
>>>> Basically, the situation is that I have table A with a field "ID".
>>>> Table B has a field for tableAID, and are "children objects". However,
>>>> I want to define a relationship that only grabs a subset of the children
>>>> objects (ie, all of table b objects which have tableAID = table A.ID
>>>> which also satisfy some other criteria). Is this possible? I know I
>>>> could define a java method, getSubsetOfChildren or some such where I
>>>> either do an in-memory filter of the child objects or else where I just
>>>> run a named query and return the resulting objects. I was just curious
>>>> if there was a way to map this directly. Thanks in advance!
>>>>
>>>> Robert
>>>
>>> ______________________________________________________________
>>> Verschicken Sie romantische, coole und witzige Bilder per SMS!
>>> Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
>>>
>>>
>>
>>
>>
>
This archive was generated by hypermail 2.0.0 : Thu Mar 03 2005 - 09:28:23 EST