[Lada-commits] [PATCH] Introduce default value vor Messregime in Messprogramm

Wald Commits scm-commit at wald.intevation.org
Tue Jul 5 18:25:28 CEST 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1467735895 -7200
# Node ID e192feaf916f30fb500340c4a93aae93cb25e9c8
# Parent  ce1ec3cbde54ab023a71c43dc41b60a3a40af6b9
Introduce default value vor Messregime in Messprogramm.

diff -r ce1ec3cbde54 -r e192feaf916f db_schema/lada_schema.sql
--- a/db_schema/lada_schema.sql	Fri Jul 01 17:36:06 2016 +0200
+++ b/db_schema/lada_schema.sql	Tue Jul 05 18:24:55 2016 +0200
@@ -573,7 +573,7 @@
     labor_mst_id character varying(5) NOT NULL
         REFERENCES stammdaten.mess_stelle,
     datenbasis_id integer NOT NULL REFERENCES stammdaten.datenbasis,
-    ba_id integer,
+    ba_id integer DEFAULT 1,
     gem_id character varying(8),
     ort_id integer NOT NULL REFERENCES stammdaten.ort,
     media_desk character varying(100),
diff -r ce1ec3cbde54 -r e192feaf916f src/main/java/de/intevation/lada/model/land/Messprogramm.java
--- a/src/main/java/de/intevation/lada/model/land/Messprogramm.java	Fri Jul 01 17:36:06 2016 +0200
+++ b/src/main/java/de/intevation/lada/model/land/Messprogramm.java	Tue Jul 05 18:24:55 2016 +0200
@@ -16,6 +16,7 @@
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
+import javax.persistence.PrePersist;
 
 
 /**
@@ -26,6 +27,14 @@
 public class Messprogramm implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    // Has to be kept in sync with database schema
+    @PrePersist
+    void setDefaults() {
+        if (baId == null) {
+            baId = 1;
+        }
+    }
+
     @Id
     @GeneratedValue(strategy=GenerationType.IDENTITY)
     @Column(name="id", unique=true, nullable=false)


More information about the Lada-commits mailing list