diff src/main/java/de/intevation/lada/rest/ProbeService.java @ 1034:61354a9fa58d schema-update

Make dynamic inserts on probe and messung objects to avoid 'not null'-constraint error.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 31 Aug 2016 15:50:54 +0200
parents 1c41c7b8f7c2
children f92c96efa976
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/ProbeService.java	Wed Aug 31 15:49:40 2016 +0200
+++ b/src/main/java/de/intevation/lada/rest/ProbeService.java	Wed Aug 31 15:50:54 2016 +0200
@@ -325,13 +325,18 @@
         /* Persist the new probe object*/
         Response newProbe = repository.create(probe, "land");
         Probe ret = (Probe)newProbe.getData();
+        // Refreshing the probe object is necessary because probe objects use
+        // dynamic-insert, meaning null values are not written to the db and not
+        // updated after insert.
+        Response refreshed =
+            repository.getById(Probe.class, ret.getId(), "land");
         /* Create and persist a new probe translation object*/
         if(violation.hasWarnings()) {
-            newProbe.setWarnings(violation.getWarnings());
+            refreshed.setWarnings(violation.getWarnings());
         }
         return authorization.filter(
             request,
-            newProbe,
+            refreshed,
             Probe.class);
     }
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)