Re: Detaching dataset on errors

Anthony & Melissa Berglas <[email protected]>
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
Hello Franck,

Hmm.   Semi consistent DataSets could get tricky.

In particular, each flush removes the record from the update list, 
one by one.  So if you were to successfully flush some records, then 
fail and rollback, the dirtyness of the flushed records would be 
lost.  When you eventually fixed the problem and committed, you would 
loose the update.

One approach would be to throw it back to the user (you).  Before 
attaching the dataset, do an explicit query looking for duplicates.

Another would be to copy the dataset before reattaching it.  Or at 
least the update list.  Messy.

Another would be to allow detachment without commitment, and just let 
the user worry about it.

Another would be to allow commit without flush.  So that any 
partially made updates go through.  But that could also messy.


What is the simplest?  Probably just allowing detach without commit 
and lots of warnings in the docs.  Messy.

I'll add session.unsafeDetachWithoutCommit.  (The required test cases 
will be a bit tricky to set up.)

(I have improved the exception processing in flush() -- the 
SException.getRecordInstance is now properly set so you can diagnose 
automatically more efficiently.)

Anthony

At 10:57 PM 9/08/2008, Franck Routier wrote:

>Hi,
>
>I have the case where I try to commitAndDetachDataSet(), but there is an
>error, say a duplicate primary key.
>
>Until now I was catching the exception and detaching the records in the
>catch block, so that they were not destroyed and could be returned back
>to the UI layer for user interaction (say, possibly, choosing another
>pk).
>
>Now I can't find any method to detach a dataset, other than
>commitAndDetachDataset().
>
>I could getDataSet() and manually setSession(null) on it, but this
>doesn't seem future safe (in a future version, detaching a dataset may
>imply other actions that simply setting session to null).
>
>So here is my question:
>1) does detaching a dataset on error seem legitimate ? (if not, what
>would be the alternative ?)
>2) should we add a method to ses.detachDataSet() ?
>
>Franck
>
>


Spreadsheet Detective,
Southern Cross Software Queensland Pty Limited
54 Gerler Street
Bardon, Queensland 4065, Australia.

Email: [email protected]
www.SpreadsheetDetective.com
Ph: +61 427 830248 (Australian Eastern Standard Time)

"If the model seems correct only because the numbers look right,
then why build the model in the first place?"

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/SimpleORM/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/SimpleORM/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
58d0b91.jpg (image/jpeg, 3.3 KB) - not displayed
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.