Re: Dealing with a commit exception....

John Huss <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAOUwSGvGksGgybGOOUxr7nTy3k92z1DAEuWGh=ax5qaRhzQ+jg@mail.gmail.com>
I think it would be better to figure out the "problem" objects before
committing by querying the DB and the object context.

On Wed, Jun 23, 2021 at 9:47 AM Tony Giaccone <[email protected]> wrote:

> I have a list of 10 new objects that I've inserted into the objectcontex
> and am about to do a commit changes on the object context.
>
> One, or more, of those entries violates a constraint and causes the commit
> changes to throw an exception.
>
> Now most of them are  probably ok, so I want to make sure they get
> inserted. How do I handle this?
>
> My first thought was to invalidate the 10 items.. then individually add
> each one back into the context and do a commit changes after each add.  Is
> that a reasonable path? Obviously the one that failed before will fail
> again, and then I can just log that, invalidate it again and keep going.
>
> Is there a better faster way to do this?
>
>
>
> Tony Giaccone
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.