diff --git a/src/main/resources/hibernate/Image.hbm.xml b/src/main/resources/hibernate/Image.hbm.xml
index 64e2b56..bdc5126 100644
--- a/src/main/resources/hibernate/Image.hbm.xml
+++ b/src/main/resources/hibernate/Image.hbm.xml
@@ -8,9 +8,9 @@
This class contains the image hashes and meta data
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/src/main/scala/com/sothr/imagetools/dao/ImageDAO.scala b/src/main/scala/com/sothr/imagetools/dao/ImageDAO.scala
index 7047fc7..4bc530f 100644
--- a/src/main/scala/com/sothr/imagetools/dao/ImageDAO.scala
+++ b/src/main/scala/com/sothr/imagetools/dao/ImageDAO.scala
@@ -9,31 +9,26 @@ import com.sothr.imagetools.image.Image
class ImageDAO {
private val sessionFactory:SessionFactory = HibernateUtil.getSessionFactory()
- private val example:Image = new Image()
def find(path:String):Image = {
val session:Session = sessionFactory.getCurrentSession
- session.beginTransaction
- val result = session.get(example.getClass, path).asInstanceOf[Image]
+ session.getTransaction.begin()
+ val result = session.get(classOf[Image], path).asInstanceOf[Image]
session.getTransaction.commit()
result
}
def save(image:Image) = {
val session:Session = sessionFactory.getCurrentSession
- session.beginTransaction
-
+ session.getTransaction.begin()
session.saveOrUpdate(image)
-
session.getTransaction.commit()
}
def save(images:List[Image]) = {
val session:Session = sessionFactory.getCurrentSession
- session.beginTransaction
-
+ session.getTransaction.begin()
for (image <- images) session.saveOrUpdate(image)
-
session.getTransaction.commit()
}
diff --git a/src/main/scala/com/sothr/imagetools/image/ImageService.scala b/src/main/scala/com/sothr/imagetools/image/ImageService.scala
index 46bd967..de49a73 100644
--- a/src/main/scala/com/sothr/imagetools/image/ImageService.scala
+++ b/src/main/scala/com/sothr/imagetools/image/ImageService.scala
@@ -48,7 +48,7 @@ object ImageService extends Logging {
try {
imageDAO.save(image)
} catch {
- case ex:Exception => error(s"Error saving up \'${image.imagePath}\' to database", ex)
+ case ex:Exception => error(s"Error saving \'${image.imagePath}\' to database", ex)
}
image
}
diff --git a/src/test/resources/hibernate/Image.hbm.xml b/src/test/resources/hibernate/Image.hbm.xml
index 64e2b56..bdc5126 100644
--- a/src/test/resources/hibernate/Image.hbm.xml
+++ b/src/test/resources/hibernate/Image.hbm.xml
@@ -8,9 +8,9 @@
This class contains the image hashes and meta data
-
-
-
-
+
+
+
+
\ No newline at end of file