@Override
    public int deleteWhere(String fieldName, String value, boolean autoCommit) throws SQLException {
    """
	For a given condition (fieldName = 'value'), delete all entities that match the condition. Because this uses the
	{@link #delete(Integer, boolean)} method, it also will delete any "child" entities that reference any entities
	matching the original query.
    """
        try {
            String tableName = String.join(".", tablePrefix, specTable.name);
            // Get the IDs for entities matching the where condition
            TIntSet idsToDelete = getIdsForCondition(tableName, fieldName, value, connection);
            TIntIterator iterator = idsToDelete.iterator();
            TIntList results = new TIntArrayList();
            while (iterator.hasNext()) {
                // For all entity IDs that match query, delete from referencing tables.
                int id = iterator.next();
                // FIXME: Should this be a where in clause instead of iterating over IDs?
                // Delete each entity and its referencing (child) entities
                int result = delete(id, false);
                if (result != 1) {
                    throw new SQLException("Could not delete entity with ID " + id);
                }
                results.add(result);
            }
            if (autoCommit) connection.commit();
            LOG.info("Deleted {} {} entities", results.size(), specTable.name);
            return results.size();
        } catch (Exception e) {
            // Rollback changes on failure.
            connection.rollback();
            LOG.error("Could not delete {} entity where {}={}", specTable.name, fieldName, value);
            e.printStackTrace();
            throw e;
        } finally {
            if (autoCommit) {
                // Always close connection if auto-committing.
                connection.close();
            }
        }
    }
@Override
    public int deleteWhere(String fieldName, String value, boolean autoCommit) throws SQLException {
        try {
            String tableName = String.join(".", tablePrefix, specTable.name);
            // Get the IDs for entities matching the where condition
            TIntSet idsToDelete = getIdsForCondition(tableName, fieldName, value, connection);
            TIntIterator iterator = idsToDelete.iterator();
            TIntList results = new TIntArrayList();
            while (iterator.hasNext()) {
                // For all entity IDs that match query, delete from referencing tables.
                int id = iterator.next();
                // FIXME: Should this be a where in clause instead of iterating over IDs?
                // Delete each entity and its referencing (child) entities
                int result = delete(id, false);
                if (result != 1) {
                    throw new SQLException("Could not delete entity with ID " + id);
                }
                results.add(result);
            }
            if (autoCommit) connection.commit();
            LOG.info("Deleted {} {} entities", results.size(), specTable.name);
            return results.size();
        } catch (Exception e) {
            // Rollback changes on failure.
            connection.rollback();
            LOG.error("Could not delete {} entity where {}={}", specTable.name, fieldName, value);
            e.printStackTrace();
            throw e;
        } finally {
            if (autoCommit) {
                // Always close connection if auto-committing.
                connection.close();
            }
        }
    }
@ Override public int deleteWhere ( String fieldName , String value , boolean autoCommit ) throws SQLException { try { String tableName = String . join ( "." , tablePrefix , specTable . name ) ; // Get the IDs for entities matching the where condition TIntSet idsToDelete = getIdsForCondition ( tableName , fieldName , value , connection ) ; TIntIterator iterator = idsToDelete . iterator ( ) ; TIntList results = new TIntArrayList ( ) ; while ( iterator . hasNext ( ) ) { // For all entity IDs that match query, delete from referencing tables. int id = iterator . next ( ) ; // FIXME: Should this be a where in clause instead of iterating over IDs? // Delete each entity and its referencing (child) entities int result = delete ( id , false ) ; if ( result != 1 ) { throw new SQLException ( "Could not delete entity with ID " + id ) ; } results . add ( result ) ; } if ( autoCommit ) connection . commit ( ) ; LOG . info ( "Deleted {} {} entities" , results . size ( ) , specTable . name ) ; return results . size ( ) ; } catch ( Exception e ) { // Rollback changes on failure. connection . rollback ( ) ; LOG . error ( "Could not delete {} entity where {}={}" , specTable . name , fieldName , value ) ; e . printStackTrace ( ) ; throw e ; } finally { if ( autoCommit ) { // Always close connection if auto-committing. connection . close ( ) ; } } }
For a given condition (fieldName = 'value'), delete all entities that match the condition. Because this uses the
{@link #delete(Integer, boolean)} method, it also will delete any "child" entities that reference any entities
matching the original query.
For a given condition ( fieldName = value ) delete all entities that match the condition . Because this uses the {