From 4b211d81909016284c04f6771c14412ec6c95e71 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 11 Dec 2013 09:09:43 +0100 Subject: [PATCH] Fix bug in archiving date. --- src/fr/devinsy/sikevadb/SQLSikevaDB.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/fr/devinsy/sikevadb/SQLSikevaDB.java b/src/fr/devinsy/sikevadb/SQLSikevaDB.java index bf8dbb0..8180b64 100644 --- a/src/fr/devinsy/sikevadb/SQLSikevaDB.java +++ b/src/fr/devinsy/sikevadb/SQLSikevaDB.java @@ -108,7 +108,8 @@ public class SQLSikevaDB implements SikevaDB { // connection = getConnection(); connection.setAutoCommit(true); - statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL"); + statement = connection + .prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL AND ARCHIVE_DATE IS NULL"); statement.setTimestamp(1, toTimestamp(element.getArchiveDate())); statement.setString(2, element.getKey()); @@ -147,7 +148,7 @@ public class SQLSikevaDB implements SikevaDB { // connection = getConnection(); connection.setAutoCommit(true); - statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?"); + statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=? AND ARCHIVE_DATE IS NULL"); statement.setTimestamp(1, toTimestamp(element.getArchiveDate())); statement.setString(2, element.getKey()); @@ -1715,7 +1716,7 @@ public class SQLSikevaDB implements SikevaDB { connection.setAutoCommit(false); // Archive existing element. - statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL"); + statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY IS NULL AND ARCHIVE_DATE IS NULL"); statement.setTimestamp(1, toTimestamp(element.getEditionDate())); statement.setString(2, element.getKey()); @@ -1784,7 +1785,7 @@ public class SQLSikevaDB implements SikevaDB { connection.setAutoCommit(false); // Archive existing element. - statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=?"); + statement = connection.prepareStatement("UPDATE sikevadb_elements SET ARCHIVE_DATE=? WHERE TOPKEY=? AND SUBKEY=? AND ARCHIVE_DATE IS NULL"); statement.setTimestamp(1, toTimestamp(element.getEditionDate())); statement.setString(2, element.getKey());