You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Julien Trolliet <jt...@c3t.fr> on 2008/05/06 17:35:37 UTC

Commit with validation errors in detail table

Hi
I have a 2 tables with a One-to-many relations. (Master-Details)
My code insert one row in the Master table and many rows in the Details  
table
at the end I do a dataContext.commitChanges();
But in some rows in the Details table I have some Validation failures
Finally I have no row commited in the DB
I would like a sort of commit with ignore errors. The good rows in Details  
will be committed in DB and the bad ones will be ignored.
How can I implement that ?
Does I need to play with Nested DataContext ?
Thank you for your clues.
Best regards.
Julien


Re: Commit with validation errors in detail table

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi Julien,

Yes, DataContext commit is all or nothing. One possible way to go  
about it is to catch the ValidationException, iterate through the list  
of failures collecting source objects of all failures. Then do  
DataContext.invalidateObjects(failed) and retry the commit.

Andrus

On May 6, 2008, at 6:35 PM, Julien Trolliet wrote:

> Hi
> I have a 2 tables with a One-to-many relations. (Master-Details)
> My code insert one row in the Master table and many rows in the  
> Details table
> at the end I do a dataContext.commitChanges();
> But in some rows in the Details table I have some Validation failures
> Finally I have no row commited in the DB
> I would like a sort of commit with ignore errors. The good rows in  
> Details will be committed in DB and the bad ones will be ignored.
> How can I implement that ?
> Does I need to play with Nested DataContext ?
> Thank you for your clues.
> Best regards.
> Julien
>
>