public boolean execDelete ( D6Model [ ] modelObjs ) { if ( modelObjs == null || modelObjs . length == 0 ) { return false ; } boolean retVal = false ; final D6CrudDeleteHelper dh = new D6CrudDeleteHelper ( modelObjs [ 0 ] . getClass ( ) ) ; final String deleteSQL = dh . createDeletePreparedSQLStatement ( ) ; log ( "#execDelete modelObjs=" + modelObjs + " delete SQL=" + deleteSQL ) ; final Connection conn = createConnection ( ) ; try { PreparedStatement preparedStmt = null ; // There is a possibility that the error occurs in one single delete // statement. // Therefore, turn the auto commit off. conn . setAutoCommit ( false ) ; preparedStmt = conn . prepareStatement ( deleteSQL ) ; for ( D6Model modelObj : modelObjs ) { dh . map ( modelObj , preparedStmt ) ; // execute SQL preparedStmt . executeUpdate ( ) ; } // Finally, commit. conn . commit ( ) ; retVal = true ; } catch ( SQLException e ) { loge ( "#execDelete" , e ) ; retVal = false ; } catch ( D6Exception e ) { // catch from helper loge ( "#execDelete" , e ) ; retVal = false ; } finally { try { conn . close ( ) ; } catch ( SQLException e ) { retVal = false ; loge ( "#execDelete" , e ) ; } } return retVal ; }
Delete the appropriate lines in specified model objects