From dfa6de258c5a29fa490fbf10f8a6396bf2b564c1 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Sun, 9 Feb 2014 10:54:49 -0600 Subject: [PATCH] Fixed an issue with persisting an Image and ImageHashDTO. Still encountering issues with "Nested Transactions Not Supported" when looking up images. Could be concurrent related, but likely the transactions aren't being closed properly on lookups, or the like. --- src/main/java/com/sothr/imagetools/App.java | 2 +- src/main/java/com/sothr/imagetools/AppCLI.java | 2 +- src/main/java/com/sothr/imagetools/AppConfig.java | 6 ++++++ src/main/resources/hibernate/Image.hbm.xml | 2 +- src/test/resources/hibernate/Image.hbm.xml | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sothr/imagetools/App.java b/src/main/java/com/sothr/imagetools/App.java index cec00f5..9bfb010 100644 --- a/src/main/java/com/sothr/imagetools/App.java +++ b/src/main/java/com/sothr/imagetools/App.java @@ -75,7 +75,7 @@ public class App extends Application @Override public void stop() throws Exception { logger.info("Image-Tools is shutting down"); - AppConfig.saveProperties(); + AppConfig.shutdown(); super.stop(); } } diff --git a/src/main/java/com/sothr/imagetools/AppCLI.java b/src/main/java/com/sothr/imagetools/AppCLI.java index 6014b3e..8b3c882 100644 --- a/src/main/java/com/sothr/imagetools/AppCLI.java +++ b/src/main/java/com/sothr/imagetools/AppCLI.java @@ -26,7 +26,7 @@ class AppCLI { CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(options, args); process(cmd); - AppConfig.saveProperties(); + AppConfig.shutdown(); System.exit(0); } catch (Exception ex) { logger.error("Unhandled exception in AppCLI",ex); diff --git a/src/main/java/com/sothr/imagetools/AppConfig.java b/src/main/java/com/sothr/imagetools/AppConfig.java index fd5f6a7..c78ed30 100644 --- a/src/main/java/com/sothr/imagetools/AppConfig.java +++ b/src/main/java/com/sothr/imagetools/AppConfig.java @@ -1,5 +1,6 @@ package com.sothr.imagetools; +import com.sothr.imagetools.dao.HibernateUtil; import com.sothr.imagetools.util.ResourceLoader; import com.sothr.imagetools.util.PropertiesService; import com.sothr.imagetools.util.PropertiesEnum; @@ -109,6 +110,11 @@ public class AppConfig { } } + public static void shutdown() { + saveProperties(); + HibernateUtil.getSessionFactory().close(); + } + public static void saveProperties() { PropertiesService.saveConf(USERPROPERTIESFILE); logger.debug("Saved properties"); diff --git a/src/main/resources/hibernate/Image.hbm.xml b/src/main/resources/hibernate/Image.hbm.xml index d8d2a30..64e2b56 100644 --- a/src/main/resources/hibernate/Image.hbm.xml +++ b/src/main/resources/hibernate/Image.hbm.xml @@ -11,6 +11,6 @@ - + \ No newline at end of file diff --git a/src/test/resources/hibernate/Image.hbm.xml b/src/test/resources/hibernate/Image.hbm.xml index d8d2a30..64e2b56 100644 --- a/src/test/resources/hibernate/Image.hbm.xml +++ b/src/test/resources/hibernate/Image.hbm.xml @@ -11,6 +11,6 @@ - + \ No newline at end of file