RE: DataObject tha contain other DataObject

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Jan 21 2005 - 10:28:42 EST

  • Next message: Pirola Davide: "RE: DataObject tha contain other DataObject"

    Oh, I just realized that the other related entity is also read via a
    stored procedure. Then instead of defining a Cayenne relationship you need
    to implement relationship handler code yourself. Note that this is for
    reading the relationship; updating object graph via stored procedures is
    much more involved...

     public ChannelDetailType getChannelDetailType()
     {
       Object value = readPropertyDirectly("channelDetailType");
       if (value instanceof Fault) {
         // manually build and run Procedure Query...
         // if "provider_id" is an object property, get it via getXYZ,
         // otherwise you can do
         // getDataContext().currentSnapshot(this).get("provider_id")
         List detailTypes = ...;

         value = detailTypes.get(0);
         writePropertyDirectly("channelDetailType", value );
       }

       return (ChannelDetailType) value;
     }

    > You'll have to define Obj/DbEntity pairs for both objects. After that
    > the steps are roughly the following:
    >
    > 1. Create a DbRelationship between Channel DbEntity and another DbEntity
    > of a related object (ChannelDetailType). Click on "Database Mapping"
    > button in the lower right corner and add a join to the relationship,
    > based on provider_id column.
    >
    > 2. Create an ObjRelationship from Channel ObjEntity to ChannelDetailType
    > ObjEntity, and map it to DbRelationship created in step (1)
    >
    > Andrus
    >
    >
    >> But if i use a stored procedure with cursor in out parameter, this is
    >> possible? I have defined a db-entity that doesn't correspond to any db
    >> table. I use it only to map that cursor.
    >>
    >> If my cursor is defined in this way (and mapped to my "Channel"
    >> dataobject):
    >> TYPE ChannelDetailType IS RECORD(id number,NAME VARCHAR2(255),
    >> provider_id NUMBER);
    >>
    >> where "provider_id" must by remapped to another dataobject, how i can
    >> say to cayenne to use this number to retrive "provider" data?
    >>
    >> I must have a cursor with all the field that compose provider data
    >> object?
    >> TYPE ChannelDetailType IS RECORD(id number,NAME VARCHAR2(255),
    >> provider_id NUMBER, provider_name VARCHAR(255), provider_type
    >> VARCHAR(255)...);
    >>
    >> Thank's
    >> Davide



    This archive was generated by hypermail 2.0.0 : Fri Jan 21 2005 - 10:28:43 EST