[Lada-commits] [PATCH 3 of 4] Catch persistence exception in case the probe is incomplete

Wald Commits scm-commit at wald.intevation.org
Tue Sep 24 13:57:57 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1380024031 -7200
# Node ID bc6d0785986f6f6a98350b46b5274f86305473fd
# Parent  3d2c53a10ee6fc69ae68e738721da1267206f935
Catch persistence exception in case the probe is incomplete.

diff -r 3d2c53a10ee6 -r bc6d0785986f src/main/java/de/intevation/lada/data/importer/LAFWriter.java
--- a/src/main/java/de/intevation/lada/data/importer/LAFWriter.java	Tue Sep 24 13:08:13 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/importer/LAFWriter.java	Tue Sep 24 14:00:31 2013 +0200
@@ -10,8 +10,12 @@
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
 import javax.persistence.Query;
 
+import org.hibernate.HibernateException;
+import org.postgresql.util.PSQLException;
+
 import de.intevation.lada.auth.AuthenticationResponse;
 import de.intevation.lada.data.Repository;
 import de.intevation.lada.model.LKommentarM;
@@ -125,7 +129,13 @@
             errors.add(new ReportData("probeId", "missing", 673));
             return false;
         }
-        persist(probe);
+        try {
+            persist(probe);
+        }
+        catch (PersistenceException e) {
+            errors.add(new ReportData("probe", "writing", 670));
+            return false;
+        }
         return true;
     }
 
@@ -319,7 +329,8 @@
      * @param probe The {@link LProbe} object.
      */
     @TransactionAttribute(TransactionAttributeType.REQUIRED)
-    private void persist(LProbe probe) {
+    private void persist(LProbe probe)
+    throws PersistenceException {
         String queryColumns = "insert into l_probe (probe_id, ba_id, test," +
             " datenbasis_id, netzbetreiber_id, mst_id, probenart_id, umw_id";
         String queryParameter = " values (:probe_id, :ba_id, :test," +


More information about the Lada-commits mailing list