public void DeleteRows(PersistentCollection collection, object id, ISessionImplementor session) { if (!isInverse) { if (log.IsDebugEnabled) { log.Debug("Deleting rows of collection: " + MessageHelper.InfoString(this, id)); } try { // delete all the deleted entries ICollection entries = collection.GetDeletes(elementType); if (entries.Count > 0) { IDbCommand st = session.Batcher.PrepareBatchCommand(SqlDeleteRowString); try { foreach (object entry in entries) { if (!hasIdentifier) { WriteKey(st, id, false, session); } WriteRowSelect(st, entry, session); session.Batcher.AddToBatch(-1); } } // TODO: change to SqlException catch (Exception e) { session.Batcher.AbortBatch(e); throw; } if (log.IsDebugEnabled) { log.Debug("done deleting collection rows"); } } else { if (log.IsDebugEnabled) { log.Debug("no rows to delete"); } } } catch (HibernateException) { // Do not call Convert on HibernateExceptions throw; } catch (Exception sqle) { throw Convert(sqle, "could not delete collection rows: " + MessageHelper.InfoString(this, id)); } } }
public void DeleteRows( PersistentCollection collection, object id, ISessionImplementor session ) { if( !isInverse ) { if( log.IsDebugEnabled ) { log.Debug( "Deleting rows of collection: " + MessageHelper.InfoString( this, id ) ); } try { // delete all the deleted entries ICollection entries = collection.GetDeletes( elementType ); if( entries.Count > 0 ) { IDbCommand st = session.Batcher.PrepareBatchCommand( SqlDeleteRowString ); try { foreach( object entry in entries ) { if( !hasIdentifier ) { WriteKey( st, id, false, session ); } WriteRowSelect( st, entry, session ); session.Batcher.AddToBatch( -1 ); } } // TODO: change to SqlException catch( Exception e ) { session.Batcher.AbortBatch( e ); throw; } if( log.IsDebugEnabled ) { log.Debug( "done deleting collection rows" ); } } else { if( log.IsDebugEnabled ) { log.Debug( "no rows to delete" ); } } } catch( HibernateException ) { // Do not call Convert on HibernateExceptions throw; } catch( Exception sqle ) { throw Convert( sqle, "could not delete collection rows: " + MessageHelper.InfoString( this, id ) ); } } }