14 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: #446: Two deletions ...
FromSent OnAttachments
Ian Kelly29 Jan 2007 17:19 
Michael Bayer29 Jan 2007 17:39 
Ian Kelly30 Jan 2007 11:35 
Michael Bayer30 Jan 2007 11:51 
Ian30 Jan 2007 12:27 
Michael Bayer30 Jan 2007 12:30 
Michael Bayer30 Jan 2007 12:40 
Michael Bayer30 Jan 2007 12:55 
Ian30 Jan 2007 13:12 
Michael Bayer30 Jan 2007 14:01 
sdob...@sistechnology.com30 Jan 2007 14:25 
Ian30 Jan 2007 14:26 
Michael Bayer30 Jan 2007 14:42 
sdob...@sistechnology.com30 Jan 2007 15:18 
Subject:[sqlalchemy] Re: #446: Two deletions cascading to the same object can result in an error
From:Michael Bayer (mike@zzzcomputing.com)
Date:01/30/2007 12:55:25 PM
List:com.googlegroups.sqlalchemy

On Jan 30, 2007, at 3:27 PM, Ian wrote:

This happens as a result of a failed session.delete() operation. The flush itself appears to be fine. If you still want an example, I can whip one up.

what kind of application are you writing where an exception occurs, and the program continues to proceed normally ?

it would be a tall order for SA to implement "atomicity" for in- memory datastructure operations and add quite a bit of overhead and complexity to all cascade operations and many others. the usual pattern here is that you start over again and use a new Session. Here's how hibernate documents its own session (which recall sets up the basic model we are working from):

http://www.hibernate.org/hib_docs/v3/reference/en/html/ transactions.html#transactions-basics-issues

"Never use the anti-patterns session-per-user-session or session-per- application (of course, there are rare exceptions to this rule). Note that some of the following issues might also appear with the recommended patterns, make sure you understand the implications before making a design decision:"

"An exception thrown by Hibernate means you have to rollback your database transaction and close the Session immediately (discussed later in more detail). If your Session is bound to the application, you have to stop the application. Rolling back the database transaction doesn't put your business objects back into the state they were at the start of the transaction. This means the database state and the business objects do get out of sync. Usually this is not a problem, because exceptions are not recoverable and you have to start over after rollback anyway."