Fix bug in archiving date.

This commit is contained in:
Christian P. MOMON 2013-12-11 09:09:43 +01:00
parent 59648da7a3
commit 4b211d8190

View file

@ -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());