aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java
diff options
context:
space:
mode:
authorGerwin Gsenger <g.gsenger@datentechnik-innovation.at>2015-01-30 12:27:45 +0100
committerGerwin Gsenger <g.gsenger@datentechnik-innovation.at>2015-01-30 12:27:45 +0100
commit78a3caea21bdd5475007b958d59b23b1d3deccfb (patch)
treea3177a7c5c6c7c8b81ebafedf09011fbf9b708ad /id/server/idserverlib/src/main/java
parent4b8f2b481636ef71146d382f386f9c297da7a64b (diff)
downloadmoa-id-spss-78a3caea21bdd5475007b958d59b23b1d3deccfb.tar.gz
moa-id-spss-78a3caea21bdd5475007b958d59b23b1d3deccfb.tar.bz2
moa-id-spss-78a3caea21bdd5475007b958d59b23b1d3deccfb.zip
small DAO code review from Thomas
Diffstat (limited to 'id/server/idserverlib/src/main/java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStoreDAOImpl.java50
1 files changed, 27 insertions, 23 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStoreDAOImpl.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStoreDAOImpl.java
index f5fb71145..4b7468013 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStoreDAOImpl.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStoreDAOImpl.java
@@ -46,24 +46,26 @@ public class ProcessInstanceStoreDAOImpl implements ProcessInstanceStoreDAO {
ProcessInstanceStore result = null;
Transaction tx = null;
- try {
- synchronized (session) {
+ synchronized (session) {
+ try {
+
tx = session.beginTransaction();
// select all where processInstanceId equals processInstanceId
Criteria criteria = session.createCriteria(ProcessInstanceStore.class);
criteria.add(Restrictions.eq("processInstanceId", processInstanceId));
result = (ProcessInstanceStore) criteria.uniqueResult();
tx.commit();
+
+ } catch (Exception e) {
+ log.error("There are multiple persisted processes with the same process instance id '{}'",
+ processInstanceId);
+ if (tx != null) {
+ tx.rollback();
+ }
+ throw e;
+ } finally {
+ MOASessionDBUtils.closeSession();
}
- } catch (Exception e) {
- log.error("There are multiple persisted processes with the same process instance id '{}'",
- processInstanceId);
- if (tx != null) {
- tx.rollback();
- }
- throw e;
- } finally {
- MOASessionDBUtils.closeSession();
}
return result;
}
@@ -74,8 +76,8 @@ public class ProcessInstanceStoreDAOImpl implements ProcessInstanceStoreDAO {
log.debug("Delete the ProcessInstanceStore for id='{}' from the database.", processInstanceId);
ProcessInstanceStore toBeDeleted = load(processInstanceId);
- boolean result = MOASessionDBUtils.delete(toBeDeleted);
- if (result == false) {
+ boolean deleted = MOASessionDBUtils.delete(toBeDeleted);
+ if (!deleted) {
log.warn("Could not delete the ProcessInstanceStore with process instance id '{}'", processInstanceId);
throw new MOADatabaseException("Could not delete the ProcessInstanceStore with process instance id '"
+ processInstanceId + "'.");
@@ -90,21 +92,23 @@ public class ProcessInstanceStoreDAOImpl implements ProcessInstanceStoreDAO {
List<ProcessInstanceStore> result = Collections.emptyList();
Transaction tx = null;
- try {
- synchronized (session) {
+ synchronized (session) {
+ try {
+
tx = session.beginTransaction();
// select all
result = session.createCriteria(ProcessInstanceStore.class).list();
tx.commit();
+
+ } catch (Exception e) {
+ log.error("A problem occured while retrieving all stored ProcessInstanceStores.");
+ if (tx != null) {
+ tx.rollback();
+ }
+ throw e;
+ } finally {
+ MOASessionDBUtils.closeSession();
}
- } catch (Exception e) {
- log.error("A problem occured while retrieving all stored ProcessInstanceStores.");
- if (tx != null) {
- tx.rollback();
- }
- throw e;
- } finally {
- MOASessionDBUtils.closeSession();
}
return result;
}