cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Dahbura <dahb...@aopslab.com>
Subject Re: Help Again on DataContext
Date Fri, 06 May 2011 18:05:19 GMT
Can you send me a little more of the code snippet please?

Is it basically registering the object into a new context or the same one it came from?

Thanks,
Tony

----- Original Message -----
From: "miguel_de_sousa" <miguel.tronix@gmail.com>
To: user@cayenne.apache.org
Sent: Wednesday, May 4, 2011 9:16:21 PM
Subject: Re: Help Again on DataContext

Hi Tony,

Sorry if this reply doesn't really help a lot but the way I do something
similar to what you're talking about is I serialise the object into xml with
XMLEncoder.encode(persistentObject) then when I get the serialised object
back I do XMLEncoder.decode(serialisedObjectXml, DataObject).

So:

     String serialisedXml = XMLEncoder.encode(persistentObject);
     
     .....

     
      XMLEncoder.decode(serialisedXml, getDataContext());
      
      try{

             getDataContext().commitChanges();
      }
      catch(CayenneRuntimeException ex){
             getDataContext().rollbackChanges();
     }

 I do this as a seperation of concerns because I use webservices as the
point of contact for all clients (webapps/Desktop GUI apps/Mobile apps), but
does work very nicely -- it also works with new objects (so I create the XML
that would represent the new object without the primary key set and Cayenne
works that out on commit).


--
View this message in context: http://cayenne.195.n3.nabble.com/Help-Again-on-DataContext-tp2899105p2901635.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Mime
View raw message