diff src/main/java/de/intevation/lada/util/data/DataTransaction.java @ 1290:14876c62f692

Push down refreshing of persisted objects deeper into the stack. There are more places besides creation of Probe objects where it is useful to return within the response what has been really written to the database (including modifications by the database itself) instead of merely the request data, e.g. creation of Ort objects, which includes database generated ort_ids.
author Tom Gottfried <tom@intevation.de>
date Wed, 08 Feb 2017 18:02:05 +0100
parents 7683c4162746
children
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/util/data/DataTransaction.java	Wed Feb 08 17:46:45 2017 +0100
+++ b/src/main/java/de/intevation/lada/util/data/DataTransaction.java	Wed Feb 08 18:02:05 2017 +0100
@@ -48,7 +48,14 @@
         EJBTransactionRolledbackException,
         TransactionRequiredException
     {
-        emp.entityManager(dataSource).persist(object);
+        EntityManager manager = emp.entityManager(dataSource);
+        manager.persist(object);
+
+        /* Refreshing the object is necessary because some objects use
+           dynamic-insert, meaning null-valued columns are not INSERTed
+           to the DB to take advantage of DB DEFAULT values, or triggers
+           modify the object during INSERT. */
+        manager.refresh(object);
     }
 
     /**
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)