changeset 1277:15700d7c00eb

According to database schema, ort.ort_typ is allowed to be NULL.
author Tom Gottfried <tom@intevation.de>
date Thu, 02 Feb 2017 15:41:05 +0100
parents efa50b39c7cc
children b63e0abcbf84
files src/main/java/de/intevation/lada/validation/rules/ort/OrtTypExists.java
diffstat 1 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/validation/rules/ort/OrtTypExists.java	Thu Feb 02 15:01:12 2017 +0100
+++ b/src/main/java/de/intevation/lada/validation/rules/ort/OrtTypExists.java	Thu Feb 02 15:41:05 2017 +0100
@@ -37,17 +37,19 @@
     public Violation execute(Object object) {
         Ort ort = (Ort)object;
 
-        QueryBuilder<OrtTyp> builder =
-            new QueryBuilder<OrtTyp>(
-                repository.entityManager("stamm"),
-                OrtTyp.class);
-        builder.and("id", ort.getOrtTyp());
-        List<OrtTyp> ots = repository.filterPlain(
-            builder.getQuery(), "stamm");
-        if (ots == null || ots.isEmpty()) {
-            Violation violation = new Violation();
-            violation.addError("ortTyp", 612);
-            return violation;
+        if (ort.getOrtTyp() != null) {
+            QueryBuilder<OrtTyp> builder =
+                new QueryBuilder<OrtTyp>(
+                    repository.entityManager("stamm"),
+                    OrtTyp.class);
+            builder.and("id", ort.getOrtTyp());
+            List<OrtTyp> ots = repository.filterPlain(
+                builder.getQuery(), "stamm");
+            if (ots == null || ots.isEmpty()) {
+                Violation violation = new Violation();
+                violation.addError("ortTyp", 612);
+                return violation;
+            }
         }
 
         return null;
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)