[Fix] Fixed postgre SQL deletion only by ID, added type

This commit is contained in:
Robert von Burg 2023-08-22 13:27:48 +02:00
parent 9c4ac3e7a4
commit f6f3a65f9c
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
1 changed files with 3 additions and 2 deletions

View File

@ -44,7 +44,7 @@ public abstract class PostgresqlDao<T extends StrolchRootElement> implements Str
private static final String updateLatestSqlS = "update {0} set latest = true where type = ? and id = ? and version = ?";
private static final String deleteElementSqlS = "delete from {0} where id = ?";
private static final String deleteElementSqlS = "delete from {0} where type = ? and id = ?";
private static final String deleteVersionSqlS = "delete from {0} where type = ? and id = ? and version = ? and latest = true";
private static final String deleteAllSqlS = "delete from {0}";
private static final String deleteAllByTypeSqlS = "delete from {0} where type = ?";
@ -511,7 +511,8 @@ public abstract class PostgresqlDao<T extends StrolchRootElement> implements Str
sql = MessageFormat.format(deleteElementSqlS, getTableName());
try (PreparedStatement preparedStatement = this.connection.prepareStatement(sql)) {
preparedStatement.setString(1, element.getId());
preparedStatement.setString(1, element.getType());
preparedStatement.setString(2, element.getId());
int modCount = preparedStatement.executeUpdate();
if (modCount != count) {