private void clearReferences(DatabaseUpdater updater, MergeMapping mapping)
        throws UpdateException {

        if (mapping.isManyToMany()) {
            String query = "DELETE FROM "+DB.ESCAPE+"" + mapping.getMappingTable() + ""+DB.ESCAPE+" WHERE "+DB.ESCAPE+""
                + mapping.getColumnFrom() + ""+DB.ESCAPE+" = '" + mapping.getValueFrom() + "'";

            if (!updater.execute(query)) {
                throw new UpdateException("unable to insert relation to mappingtable");
            }
        } else if (mapping.isManyToOne()) {
            String query = "UPDATE "+DB.ESCAPE+"" + mapping.getMappingTable() + ""+DB.ESCAPE+" SET "+DB.ESCAPE+""
                + mapping.getColumnFrom() + ""+DB.ESCAPE+" = 'NULL' WHERE "+DB.ESCAPE+"" + mapping.getColumnFrom() + ""+DB.ESCAPE+" = '"
                + mapping.getValueFrom() + "'";

            if (!updater.execute(query)) {
                throw new UpdateException("unable to insert relation to mappingtable");
            }
        }
    }