Re: Survey: usage scenarios/performance/mile stone wishlist

From: Andrus (andru..bjectstyle.org)
Date: Sun Dec 01 2002 - 19:28:01 EST

  • Next message: martin ruff: "filtering objects in relation"

    Ok, I translated this to English with Google, so at least I have some idea
    what this is about (1 month of German I took 7 years ago is obviously not
    sufficient :-)). Anyway, Let me try to answer your question. I can see that
    you have already figured how to chain expressions, so my previous email may
    be redundant.

    If I understand this correctly, the remaining problem is that
    "employeeidexpr" qualifier is not being used, right? Is there an
    ObjAttribute called "fkEmployeeid" in the "Reportingdates" ObjEntity?

    Anyway, for further debugging you may do the following:

    1. you could turn on SQL logging. Some tips how to do that are given here:

    http://objectstyle.org/cayenne/lists/cayenne-devel/2002/11/0082.html

    2. you may send you datamap XML file either to this list or to me privately
    (if it is too big or if you don't want it to be public)

    Another hint, and maybe this is the way to go in your case. Normally it is
    not a good idea to use primary/foreign keys explicitly in the Java code.
    After all, O/R is intended to hide such DB details from the object model.
    So your Reportingdates entity would have a to-one relationship to an
    Employee entity, and after getting hold of an Employee object with id 16
    (whatever way you do that), you may build a query like this (given the
    relationship name "toEmployee"):

    Employee empl = ...;
    Expression employeeidexpr = ExpressionFactory.binaryPathExp(
                                              Expression.EQUAL_TO,
                                              "toEmployee",
                                              empl);

    This is much cleaner than using id's and is in the spirit of Cayenne design.

    I hope this helps.

    Andrus

    >im moment habe ich damit leider noch grosse probleme, vielleicht kannst
    >Du mir dabei einen tip geben, habe schon recht viel zeit damit
    >verbracht, auch schon um userforum gepostet, aber leider noch keine
    >antwort bekommen folgender sachverhalt:
    >habe folgende tabelle:
    >CREATE TABLE reportingdates(
    >id serial NOT NULL PRIMARY KEY,
    >fk_employeeid int4 NOT NULL,
    >reportingdate date NOT NULL);
    >
    >moechte nun allte eintraege fuer einen bestimmten angestellen in einem
    >zeitraum, also z.b. alle eintraege fuer den angestellten 16 vom 1.8.2002
    > bis 1.9.2002
    >was ich schon versuchte:
    > Expression employeeidexpr = ExpressionFactory.binaryPathExp(
    > Expression.EQUAL_TO,
    > "fkEmployeeid",
    > employeeID);
    > Expression begindateexpr = ExpressionFactory. binaryPathExp(
    > Expression.GREATER_THAN_EQUAL_TO,
    > "reportingdate",
    > beginDate);
    > Expression enddateexpr = ExpressionFactory.binaryPathExp(
    > Expression.LESS_THAN_EQUAL_TO,
    > "reportingdate",
    > endDate);
    > SelectQuery query = new SelectQuery("Reportingdates",
    > employeeidexpr);
    > query.andQualifier(begindateexpr);
    > query.andQualifier(enddateexpr);
    > query.addOrdering("reportingdate", true);
    > return theDataContext.performQuery(query);
    >
    >liefert mir zwar schon mal alle eintraege vom 1.8.2002-1.9.2002 aber
    >dann auch noch alle eintraege fuer den benutzer 16
    >
    >jede hilfe ist sehr willkommen :-)))
    >besten dank
    >gruss martin



    This archive was generated by hypermail 2.0.0 : Sun Dec 01 2002 - 19:27:04 EST