Thank you Andrus, I let you know If I find more specific problems in the process
----- Orjinal Mesaj ----- Kimden: Andrus Adamchik Tarih: Thursday, April 13, 2006 14:05 Konu: Re: Object migrates between DataDomains Kime: [email protected] > At this point to be able to help you I'd have to actually write > a > test app that does what you are doing, and perform some > debugging. > Unfortunately I can't do it right now, as this functionality is > kind > of a byproduct of other features (so it doesn't yet look like > a > Cayenne bug to me), and I have to work on other things. > > I guess you'll have to poke around on your own. If you find > more > specific problems in the process, please let us know - maybe we > can > fix them, but I can't investigate this right now, sorry. > > Andrus > > > On Apr 13, 2006, at 2:37 PM, [EMAIL PROTECTED] wrote: > > > Hi, > > > > I have some problems. I download the cayenne-1.2-dev-2006-4- > 12.tar > > as you said. I use the your definitions but > targetContext.onSync > > throws below exception when localContext.commitChanges(). > > [EMAIL PROTECTED] > > org.objectstyle.cayenne.property.PropertyAccessException: > [v.1.2- > > dev-2006-4-12 April 12 2006] Error reading DataObject > property: name > > at > > > org.objectstyle.cayenne.property.DataObjectAccessor.readPropertyDirect > > ly(DataObjectAccessor.java:98) > > at > > > org.objectstyle.cayenne.property.SimpleProperty.readPropertyDirectly > > (SimpleProperty.java:110) > > at > org.objectstyle.cayenne.property.SimpleProperty.readProperty > > (SimpleProperty.java:81) > > at org.objectstyle.cayenne.access.ObjectDiff$4.visitProperty > > (ObjectDiff.java:210) > > at org.objectstyle.cayenne.property.SimpleProperty.visit > > (SimpleProperty.java:94) > > at > > > org.objectstyle.cayenne.property.BaseClassDescriptor.visitProperties > > (BaseClassDescriptor.java:247) > > at > > > org.objectstyle.cayenne.access.ObjectDiff.applySimplePropertyChanges > > (ObjectDiff.java:206) > > at org.objectstyle.cayenne.access.ObjectDiff.access$100 > > (ObjectDiff.java:28) > > at org.objectstyle.cayenne.access.ObjectDiff$2.apply > > (ObjectDiff.java:105) > > at org.objectstyle.cayenne.graph.CompoundDiff.apply > > (CompoundDiff.java:133) > > at org.objectstyle.cayenne.access.ObjectStoreGraphDiff.apply > > (ObjectStoreGraphDiff.java:151) > > at org.objectstyle.cayenne.access.DataContext.onContextFlush > > (DataContext.java:1171) > > at org.objectstyle.cayenne.access.DataContext.onSync > > (DataContext.java:1148) > > at tr.com.htr.hgys.db.base.DataListener.graphFlushed > > (DataListener.java:66) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > > at java.lang.reflect.Method.invoke(Unknown Source) > > at org.objectstyle.cayenne.util.Invocation.fire(Invocation.java:240) > > at org.objectstyle.cayenne.event.EventManager$Dispatch.fire > > (EventManager.java:433) > > at org.objectstyle.cayenne.event.DispatchQueue.dispatchEvent > > (DispatchQueue.java:182) > > at org.objectstyle.cayenne.event.DispatchQueue.dispatchEvent > > (DispatchQueue.java:94) > > at org.objectstyle.cayenne.event.EventManager.dispatchEvent > > (EventManager.java:372) > > at org.objectstyle.cayenne.event.EventManager.postEvent > > (EventManager.java:343) > > at > > > org.objectstyle.cayenne.access.DataContext.fireDataChannelCommitted > > (DataContext.java:1616) > > at org.objectstyle.cayenne.access.DataContext.flushToParent > > (DataContext.java:1225) > > at org.objectstyle.cayenne.access.DataContext.commitChanges > > (DataContext.java:1121) > > at tr.com.htr.hgys.db.base.DbObject.commitChanges(DbObject.java:246) > > at tr.com.htr.hgys.db.Title.setTitle(Title.java:101) > > > > > > ----- Orjinal Mesaj ----- > > Kimden: Andrus Adamchik > > Tarih: Wednesday, April 12, 2006 13:23 > > Konu: Re: Object migrates between DataDomains > > Kime: [email protected] > > > >> > >> On Apr 12, 2006, at 12:33 PM, [EMAIL PROTECTED] wrote: > >> > >>> For update:??? > >>> ClassDescriptor descriptor = > >>> > >> localContext.getEntityResolver().getClassDescriptor(obj.getClass > >>> ().getSimpleName()); > >>> System.err.println(new > >> DeepMergeOperation(ctx).merge(obj, > >>> descriptor)); > >>> ctx.commitChanges(); > >> > >> Ok, so you have something akin to a replication mechanism. Let's > >> try > >> putting the new 1.2 DataChannel API to work. This is an > >> unforeseen > >> use of such API, but looks like it might work and actually allow > >> you > >> to synchronize all changes of the entire context at once > >> (instead of > >> object by object). I have no time right now to test a fully > >> working > >> example (and the API is new so there is no docs yet), but let > >> me > >> outline the possible approach. > >> > >> * Get the latest Cayenne nightly build (it fixes some > >> DataChannel > >> event bugs). > >> > >> * On commit DataContext (which is itself a DataChannel) > >> broadcasts > >> two GraphEvents - one that contains committed context changes > >> and > >> another one with generated PK (all changes are represented > >> as > >> GraphDiff instances). See 'DataContext.flushToParent(..)' for > >> details > >> on how the events are sent. > >> > >> * You can register your own listener for the *source* > >> DataContext > >> (look at DataContext.setChannel(..) on how to register a > >> listener) > >> and apply the first group of changes to the *target* DataContext > >> via > >> DataContext.onSync(..): > >> > >> GraphEvent e; > >> > >> // first type of event > >> if(e.getSource() == sourceContext && e.getPostedBy() == > >> sourceContext) { > >> targetContext.onSync(sourceContext, > >> e.getDiff(), > >> DataChannel.FLUSH_NOCASCADE_SYNC); > >> } > >> > >> * Applying PK changes is less trivial, as onSync won't > >> work... > >> Probably you'll have to repost this event on behalf of > >> targetContext's channel so that target context catches it and > >> updates > >> itself accordingly. > >> > >> // second type of event with PKs > >> else if(e.getSource() == sourceContext && e.getPostedBy() > >> == > >> sourceContext.getChannel()) { > >> ??? > >> } > >> > >> > >> Andrus > > >
