cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Anderson <ken.ander...@amphorainc.com>
Subject Re: Staged saves pattern ?
Date Wed, 28 Mar 2018 22:42:29 GMT
That's exactly what we want to do - save once at the end.  However, we have 2 problems:

1. How do we find the objects that we already created but haven't saved yet
2. How do we roll back each line if there's an error?  Not a DB error, but the logic gets
so far, and then determines that there's no way to continue so we must skip this line.

Ken

On 3/28/18, 6:07 PM, "John Huss" <johnthuss@gmail.com> wrote:

    Well, you could just save once at the end.  Why do you need to save
    multiple times during the processing?  Validation exceptions and Optimistic
    Locking errors could be handled in the save with some custom logic and a
    retry.

    Or if this isn't a super long process you can use a database transaction to
    allow saving multiple times without actually having that data be visible
    outside of the transaction.


    On Wed, Mar 28, 2018 at 6:56 AM Ken Anderson <ken.anderson@amphorainc.com>
    wrote:

    > 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.
    >


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.
Mime
View raw message