Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
clausnagel committed Jan 14, 2025
1 parent b0a9bbc commit 0d21de1
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
import org.citydb.sqlbuilder.query.Select;
import org.citydb.sqlbuilder.schema.Table;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.sql.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
Expand All @@ -40,6 +37,7 @@ public class DuplicateFinder {
private final Map<String, Boolean> objectIds;
private final Map<Long, Boolean> databaseIds;
private final int batchSize;
private final Connection connection;
private final PreparedStatement stmt;
private final Set<String> batches = new HashSet<>();

Expand All @@ -48,14 +46,15 @@ public class DuplicateFinder {
this.databaseIds = databaseIds;

batchSize = adapter.getSchemaAdapter().getMaximumNumberOfItemsForInOperator();
connection = adapter.getPool().getConnection();
Table table = Table.of(org.citydb.database.schema.Table.FEATURE.getName(),
adapter.getConnectionDetails().getSchema());
Select select = Select.newInstance()
.select(table.columns("objectid", "id"))
.from(table)
.where(table.column("objectid").in(Collections.nCopies(batchSize, Placeholder.empty()))
.and(table.column("termination_date").isNull()));
stmt = adapter.getPool().getConnection().prepareStatement(select.toSql());
stmt = connection.prepareStatement(select.toSql());
}

void process(Feature feature) throws SQLException {
Expand Down Expand Up @@ -108,7 +107,11 @@ private void executeBatch() throws SQLException {
}

void close() throws SQLException {
executeBatch();
stmt.close();
try {
executeBatch();
stmt.close();
} finally {
connection.close();
}
}
}

0 comments on commit 0d21de1

Please sign in to comment.