diff --git a/projects/saturn/src/main/java/io/fairspace/saturn/services/views/ViewStoreClient.java b/projects/saturn/src/main/java/io/fairspace/saturn/services/views/ViewStoreClient.java index c74d6d0df..654560944 100644 --- a/projects/saturn/src/main/java/io/fairspace/saturn/services/views/ViewStoreClient.java +++ b/projects/saturn/src/main/java/io/fairspace/saturn/services/views/ViewStoreClient.java @@ -203,17 +203,13 @@ public void addLabel(String id, String type, String label) throws SQLException { public int updateRows(String view, List> rows, boolean bulkInsert) throws SQLException { var viewTable = configuration.viewTables.get(view); var config = configuration.viewConfig.get(view); - // Find the columns for which there are values in the rows + // Find the columns in the rows of type different from Set var columnNames = rows.stream() - .flatMap(row -> row.entrySet().stream() - .filter(entry -> entry.getValue() != null) - .map(Map.Entry::getKey)) + .flatMap(row -> row.keySet().stream()) .distinct() .filter(columnName -> config.columns.stream() - .noneMatch(column -> - // Skip value set columns - column.name.equalsIgnoreCase(columnName) && column.type.isSet())) - .collect(Collectors.toList()); + .noneMatch(column -> column.name.equalsIgnoreCase(columnName) && column.type.isSet())) + .toList(); if (columnNames.isEmpty()) { return 0; } @@ -228,7 +224,7 @@ public int updateRows(String view, List> rows, boolean bulkI for (var row : rows) { var values = columnNames.stream() .map(columnName -> row.getOrDefault(columnName, null)) - .collect(Collectors.toList()); + .toList(); var id = (String) row.get("id"); var exists = (!bulkInsert) && rowExists(viewTable.name, id); if (exists) { diff --git a/projects/saturn/src/main/java/io/fairspace/saturn/services/views/ViewUpdater.java b/projects/saturn/src/main/java/io/fairspace/saturn/services/views/ViewUpdater.java index 39d8d8878..289f1aedc 100644 --- a/projects/saturn/src/main/java/io/fairspace/saturn/services/views/ViewUpdater.java +++ b/projects/saturn/src/main/java/io/fairspace/saturn/services/views/ViewUpdater.java @@ -176,10 +176,7 @@ public void updateSubject(Node subject) { try { for (var column : view.columns) { var objects = retrieveValues(graph, subject, column.source); - if (objects.isEmpty()) { - continue; - } - row.put(column.name, getValue(column, objects.get(0))); + row.put(column.name, objects.isEmpty() ? null : getValue(column, objects.getFirst())); } viewStoreClient.updateRows(view.name, List.of(row), false); } catch (SQLException e) {