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 Tue, 11 Apr 2006 14:52:36 GMT
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