Browse Source

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.

master
Drew Short 11 years ago
parent
commit
dfa6de258c
  1. 2
      src/main/java/com/sothr/imagetools/App.java
  2. 2
      src/main/java/com/sothr/imagetools/AppCLI.java
  3. 6
      src/main/java/com/sothr/imagetools/AppConfig.java
  4. 2
      src/main/resources/hibernate/Image.hbm.xml
  5. 2
      src/test/resources/hibernate/Image.hbm.xml

2
src/main/java/com/sothr/imagetools/App.java

@ -75,7 +75,7 @@ public class App extends Application
@Override @Override
public void stop() throws Exception { public void stop() throws Exception {
logger.info("Image-Tools is shutting down"); logger.info("Image-Tools is shutting down");
AppConfig.saveProperties();
AppConfig.shutdown();
super.stop(); super.stop();
} }
} }

2
src/main/java/com/sothr/imagetools/AppCLI.java

@ -26,7 +26,7 @@ class AppCLI {
CommandLineParser parser = new BasicParser(); CommandLineParser parser = new BasicParser();
CommandLine cmd = parser.parse(options, args); CommandLine cmd = parser.parse(options, args);
process(cmd); process(cmd);
AppConfig.saveProperties();
AppConfig.shutdown();
System.exit(0); System.exit(0);
} catch (Exception ex) { } catch (Exception ex) {
logger.error("Unhandled exception in AppCLI",ex); logger.error("Unhandled exception in AppCLI",ex);

6
src/main/java/com/sothr/imagetools/AppConfig.java

@ -1,5 +1,6 @@
package com.sothr.imagetools; package com.sothr.imagetools;
import com.sothr.imagetools.dao.HibernateUtil;
import com.sothr.imagetools.util.ResourceLoader; import com.sothr.imagetools.util.ResourceLoader;
import com.sothr.imagetools.util.PropertiesService; import com.sothr.imagetools.util.PropertiesService;
import com.sothr.imagetools.util.PropertiesEnum; 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() { public static void saveProperties() {
PropertiesService.saveConf(USERPROPERTIESFILE); PropertiesService.saveConf(USERPROPERTIESFILE);
logger.debug("Saved properties"); logger.debug("Saved properties");

2
src/main/resources/hibernate/Image.hbm.xml

@ -11,6 +11,6 @@
<property name="thumbnailPath" column="thumbnail_path" type="string"/> <property name="thumbnailPath" column="thumbnail_path" type="string"/>
<property name="width" column="width" type="int"/> <property name="width" column="width" type="int"/>
<property name="height" column="height" type="int"/> <property name="height" column="height" type="int"/>
<one-to-one name="hashes" class="com.sothr.imagetools.dto.ImageHashDTO"/>
<one-to-one name="hashes" class="com.sothr.imagetools.dto.ImageHashDTO" cascade="save-update, delete"/>
</class> </class>
</hibernate-mapping> </hibernate-mapping>

2
src/test/resources/hibernate/Image.hbm.xml

@ -11,6 +11,6 @@
<property name="thumbnailPath" column="thumbnail_path" type="string"/> <property name="thumbnailPath" column="thumbnail_path" type="string"/>
<property name="width" column="width" type="int"/> <property name="width" column="width" type="int"/>
<property name="height" column="height" type="int"/> <property name="height" column="height" type="int"/>
<one-to-one name="hashes" class="com.sothr.imagetools.dto.ImageHashDTO"/>
<one-to-one name="hashes" class="com.sothr.imagetools.dto.ImageHashDTO" cascade="save-update, delete"/>
</class> </class>
</hibernate-mapping> </hibernate-mapping>
Loading…
Cancel
Save