aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web-db
diff options
context:
space:
mode:
authorThomas <>2023-04-11 18:11:27 +0200
committerThomas <>2023-04-11 18:11:27 +0200
commit93f1fcda5b0e619a75081bf55af0c0ab1a4b9a32 (patch)
tree6b5e2d2e7367c7427f55e0d8afa66dea8f72bf87 /pdf-as-web-db
parent0e5abb54a7ccc39d2b2e2f6b4baee9fee8b60c03 (diff)
downloadpdf-as-4-93f1fcda5b0e619a75081bf55af0c0ab1a4b9a32.tar.gz
pdf-as-4-93f1fcda5b0e619a75081bf55af0c0ab1a4b9a32.tar.bz2
pdf-as-4-93f1fcda5b0e619a75081bf55af0c0ab1a4b9a32.zip
fix(database): db clean-up not properly working
from TUG: cleanOldRequests() started a transaction but never commited it which means none of the old entries were deleted. Add a call to commit() to fix this.
Diffstat (limited to 'pdf-as-web-db')
-rw-r--r--pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java b/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java
index 92e32e1e..e5a789d2 100644
--- a/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java
+++ b/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java
@@ -4,12 +4,13 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
-import javax.imageio.spi.ServiceRegistry;
-import javax.transaction.Transaction;
-
-import org.apache.cxf.service.invoker.SessionFactory;
-import org.apache.cxf.transport.Session;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.query.Query;
+import org.hibernate.service.ServiceRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,6 +59,7 @@ public class DBRequestStore implements IRequestStore {
+ " where req.created < :date");
query.setCalendar("date", calendar);
query.executeUpdate();
+ tx.commit();
} catch (final Throwable e) {
logger.error("Failed to save Request", e);
tx.rollback();
@@ -92,7 +94,7 @@ public class DBRequestStore implements IRequestStore {
+ " where req.created < :date");
queryResponse.setCalendar("date", calendar);
queryResponse.executeUpdate();
-
+
} finally {
if (session != null) {
session.close();