Thank's.
I have implemented a workaround similar.
My DataObject "channel" treats only id value (in my example "provider_id").
Instead of run Procedure Query, i instantiate a empty Provider object whit only id field valorized.
I have a class loader that run procedure query (DAO pattern)..one for a type... so when i call a "ChannelLoader" i firstable get a Channel dataobjet (with only a empty "Provider" data object), then i use the "id" field to call another DAO ("ProviderLoader") to valorize remainig fileds.
Thank's for the time you spend to help me.
Davide
-----Original Message-----
From: Andrus Adamchik [mailto:andru..bjectstyle.org]
Sent: venerdě 21 gennaio 2005 16.29
To: cayenne-use..bjectstyle.org
Subject: 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 - 11:51:47 EST