From 93f1fcda5b0e619a75081bf55af0c0ab1a4b9a32 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 11 Apr 2023 18:11:27 +0200 Subject: 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. --- .../java/at/gv/egiz/pdfas/web/store/DBRequestStore.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'pdf-as-web-db') 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(); -- cgit v1.2.3