Re: query-attributes?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Mar 03 2005 - 09:39:24 EST

  • Next message: Francesca: "error when run! What can I do?"

    I agree. That's why I still haven't released that simple DataRow to POJO
    converter that I mentioned. It is important to handle the relationships
    (even if though non-standard join semantics would force them to be
    read-only) - this is all just different aspects of the same feature in my
    mind.

    BTW, on a somewhat unrelated note, M3 will have suport for converting a
    list of DataRows with keys following certain naming conventions into a
    tree of related objects (that's a stanalone feature + a new way to do
    prefetching). This way you can create highly optimized SQL with customized
    join logic and map a resulting join product into a object hierarchy. This
    will be yet another way to bridge reational and object structures.

    Andrus

    > 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



    This archive was generated by hypermail 2.0.0 : Thu Mar 03 2005 - 09:39:27 EST