All,

We have a process that reads in a file and, for each line, creates or edits 
objects in the object graph.  We only want to commit to the database once at 
the end.

We have a finite set of lines, so memory is not an issue.  We need to save only 
once because saving will actually fire triggers that will start doing other 
things to the database, which will then lead to optimistic lock exceptions for 
us if we have data that overlaps (which we do).

Please don’t suggest we change how the trigger pattern works – it’s a big 
system and we don’t have control over it.

So, what we’ve toyed with is using a parent/child context arrangement, where 
each line is processed in a child, and assuming everything goes OK, we commit 
only to the parent.  This works well as long as we don’t need to access the 
same objects multiple times, but unfortunately, we do.  We can reach into the 
parent context’s unsaved objects, but those objects do not have any 
relationships since they were built in the child context.  This makes things 
painful.

In EOF, I might consider using a single context and undo, but it doesn’t seem 
like Cayenne has this kind of functionality.

Thoughts?  Suggestions?  In EOF, I had once written a layer that intercepted 
all queries and tried to find the correct object in unsaved objects, but I 
don’t have nearly enough experience with Cayenne to do that.

Thanks!
Ken

Confidentiality Notice: This e-mail and accompanying documents contain 
confidential information intended for a specific individual and purpose. This 
e-mailed information is private and protected by law. If you are not the 
intended recipient, you are hereby notified that any disclosure, copying, or 
distribution, or the taking of any action based on the contents of this 
information, is strictly prohibited.

Reply via email to