cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Object migrates between DataDomains
Date Wed, 12 Apr 2006 08:09:50 GMT
Can you explain what are you trying to achieve in general (i.e.  
scenario details)? I may be able to help then.

Andrus

On Apr 12, 2006, at 12:01 PM, emre.yilmaz@htr.com.tr wrote:

> Hi Andrus ,
>
> I tested DeepMergeOperation. Merged object on targetContext  
> (anotherObject) is created as I desired with its relations but  I  
> observe actually anotherObject is not created physically on  
> database .I used the targetContext.commitChanges() to create on  
> database but not create it.What is the reason of this or how can  
> commit created anotherObject on targetContext.
>
>
> ----- Orjinal Mesaj -----
> Kimden: Andrus Adamchik
> Tarih: Tuesday, April 11, 2006 17:53
> Konu: Re: Object migrates between DataDomains
> Kime: cayenne-user@incubator.apache.org
>
>> Yeah, default mechanism is "lazy" in that it assumes that
>> related
>> objects can be resolved from the database on demand. Copying
>> a
>> subgraph of new objects is a bit more tricky. In 1.2 you can
>> try
>> using  org.objectstyle.cayenne.util.DeepMergeOperation for
>> your
>> purpose. Something like this:
>>
>> DataContext srcContext, targetContext;
>> DataObject object;
>>
>> ClassDescriptor descriptor =
>>
>> targetContext.getEntityResolver().getClassDescriptor("MyEntity");
>> DataObject anotherObject = new
>> DeepMergeOperation(targetContext).merge
>> (object, descriptor);
>>
>> DeepMergeOperation merges everything that is attached to a
>> given
>> object and is already resolved in memory. If you need to
>> implement
>> different logic, you can write your own version using
>> DeepMergeOperation as a template. An example of a different
>> graph
>> traversal termination logic is ObjectDetachOperation that is
>> based on
>> a preset tree of relationships.
>>
>> Andrus
>>
>> On Apr 11, 2006, at 5:50 PM, emre.yilmaz@htr.com.tr wrote:
>>
>>> Hi,
>>>
>>> Thank you for help. I make the changes as you say but I
>> observe the
>>> DataContext.localObject(..) not set the relations (forign
>> key
>>> id's).Can you help me for migrating
>>> objects with its relations through DataDomains.
>>>
>>> ----- Orjinal Mesaj -----
>>> Kimden: Andrus Adamchik <andrus@objectstyle.org>
>>> Tarih: Monday, April 10, 2006 11:55
>>> Konu: Re: Object migrates between DataDomains
>>> Kime: cayenne-user@incubator.apache.org
>>>
>>>>
>>>> On Apr 10, 2006, at 11:48 AM, emre.yilmaz@htr.com.tr wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Is there a easy way to migrate created objects from one
>>>> DataDomain
>>>>> to other DataDomain.
>>>>>
>>>>> Thank you...
>>>>
>>>>
>>>> Technically DataObject belongs to a DataContext, so we should be
>>>> speaking about moving objects between DataContexts (that in turn
>>>> can
>>>> belong to different DataDomains). This is done with
>>>> DataContext.localObject(..)
>>>>
>>>> http://objectstyle.org/confluence/display/CAYDOC/Moving+Objects
>>>> +Between+Contexts
>>>>
>>>> Of course object mappings have to be compatible in both domains
>>>> involved.
>>>>
>>>> Andrus
>>>>
>>>>
>>>
>>
>>


Mime
View raw message