Fixed commit upon deletion of centroids

This commit is contained in:
Fabio Sinibaldi 2021-08-04 17:09:30 +02:00
parent 38a8b89963
commit cd04e5f49e
2 changed files with 9 additions and 3 deletions

View File

@ -108,9 +108,14 @@ public class PostgisDBManager implements PostgisDBManagerI {
@Override
public int deleteByFieldValue(PostgisTable target, PostgisTable.Field field, Object value) throws SQLException {
PreparedStatement stmt = conn.prepareStatement(target.getDeleteByFieldStatement(field));
String query=target.getDeleteByFieldStatement(field);
log.debug("Preparing DELETE SQL {} with field {} = {} ",query,field,value);
PreparedStatement stmt = conn.prepareStatement(query);
target.setObjectInPreparedStatement(field, value, stmt, 1);
return stmt.executeUpdate();
int result=stmt.executeUpdate();
log.debug("DELETED {} rows ",result);
return result;
}
@Override

View File

@ -105,7 +105,8 @@ public class PostgisIndex {
PostgisTable centroidsTable=getCentroidsTable();
log.debug("Deleting centroid if present. ID is "+record.getMongo_id());
int result= db.deleteByFieldValue(centroidsTable, new Field(DBConstants.Concessioni.PRODUCT_ID,FieldType.TEXT), record.getMongo_id());
log.info("Removed {} entries from gif Index with mongo id {} ",record.getMongo_id());
db.commit();
log.info("Removed {} entries from gif Index with mongo id {} ",result,record.getMongo_id());
}catch(Exception e) {
log.warn("Unable to remove centroid ",e);
}