Re: transient relations

From: Mike Kienenberger (mkienen..laska.net)
Date: Thu Oct 28 2004 - 15:58:59 EDT

  • Next message: Mike Kienenberger: "Re: {Filename?} Memory Leak?"

    =?iso-8859-1?Q? J=FCrgen=20Saar ?= <jsaa..eb.de> wrote:
    > Hi,
    >
    > I'm trying to design a transient relation, the List with the DataObjects
    will be build in the ObjEntity-Class.
    >
    > In the modeler there is no posibility to create only an ObjEntity. So I
    created a DbEntity, that does'n exists in the Database with an ObjEntity and
    overwrote the readProperty() to ensure that cayenne does no database read.
    >
    > Is this the only way, or is there a better way to design relationdata that
    are result of the business logic.

    Not completely sure I follow what you're trying to do, but you can certainly
    add additional methods to your DataObject subclass to return whatever data
    you like.

    Ie, I have an Account object, and I added a "getAmountDue()" method to it
    that computes the balance for that account based on whether certain other
    data records exist in the database.

    I also have a User object that has a "getAvailableAccountsList" method that
    generates a list of Account objects based on business logic.

            public List getAvailableAccountsList()
            {
                    List anAccountList = new ArrayList();
                    Iterator userAccountRelationshipIterator =
    this.getUserAccountRelationshipList().iterator();
                    while (userAccountRelationshipIterator.hasNext())
                    {
                            UserAccountRelationship aUserAccountRelationship =
    (UserAccountRelationship)userAccountRelationshipIterator.next();
                            Account anAccount = aUserAccountRelationship.getAccount();

                            anAccountList.add(anAccount);
                    }

                    List orderings = new ArrayList();
            orderings.add(new Ordering("statusSortOrderValue", true));
                    orderings.add(new Ordering("isBTAAccount", true));
            orderings.add(new Ordering("accountNumber", true));

                    Ordering.orderList(anAccountList, orderings);

                    return anAccountList;
            }

    This particular relationship can't be modeled because "statusSortOrderValue"
    is a complex derived attribute of Account which cannot be expressed in SQL
    (or at least not in any easy way).

    -Mike



    This archive was generated by hypermail 2.0.0 : Thu Oct 28 2004 - 15:57:37 EDT