cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Easy way to update objects
Date Wed, 27 Apr 2011 09:15:50 GMT
"Attach" operation is a bit alien to Cayenne. We have a TODO somewhere in Jira, but I guess
nobody wanted it badly enough to implement. The closest thing to it is this:

MyObject detached = ;
ObjectId id = new ObjectId(..); // create it based on PK values... or maybe your object already
has an ObjectId
MyObject attached = (MyObject) context.localObject(id, detached);

However it is (1) verbose, (2) does not traverse relationships and (3) is used by framework
to transfer committed objects to upstream contexts so the resulting attached object will end
up as COMMITTED, not MODIFIED as you would need.

I haven't actually tried whether you can overcome #3 (e.g. by making a dummy modification)
to ensure Cayenne can commit your modifications.

Andrus

On Apr 21, 2011, at 5:15 PM, Christian Grobmeier wrote:
> Hi,
> 
> I have a detached object with a PK. I would like to update a matching
> object in the database with the values of the detached object.
> 
> Can this easily done?
> 
> At the moment i see only the chance to select an object from the
> database and manually copy over all the new values to the attached
> object. I can imagine you have some cool feature I couldn't find.
> 
> Cheers
> Christian
> 


Mime
View raw message