[Lada-commits] [PATCH 5 of 9] Added one to one realtion.^

Wald Commits scm-commit at wald.intevation.org
Wed Feb 11 13:02:43 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1423655502 -3600
# Node ID 76c0cc6d2d852fd5431595bbbf8fcb40210a5b03
# Parent  248df70de37d656171d22ff69ac3b2155456bb83
Added one to one realtion.^

diff -r 248df70de37d -r 76c0cc6d2d85 src/main/java/de/intevation/lada/model/land/LProbe.java
--- a/src/main/java/de/intevation/lada/model/land/LProbe.java	Wed Feb 11 12:50:52 2015 +0100
+++ b/src/main/java/de/intevation/lada/model/land/LProbe.java	Wed Feb 11 12:51:42 2015 +0100
@@ -11,8 +11,11 @@
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
 import de.intevation.lada.model.Probe;
 
 
@@ -24,6 +27,9 @@
 public class LProbe extends Probe {
     private static final long serialVersionUID = 1L;
 
+    @OneToOne(mappedBy="probe")
+    private ProbeTranslation probeTranslation;
+
     @Column(name="hauptproben_nr")
     private String hauptprobenNr;
 
@@ -107,6 +113,15 @@
         this.solldatumEnde = solldatumEnde;
     }
 
+    @JsonIgnore
+    public ProbeTranslation getProbeTranslation() {
+        return probeTranslation;
+    }
+
+    public void setProbeTranslation(ProbeTranslation probeTranslation) {
+        this.probeTranslation = probeTranslation;
+    }
+
     public String getHauptprobenNr() {
         return this.hauptprobenNr;
     }
@@ -114,4 +129,10 @@
     public void setHauptprobenNr(String hauptprobenNr) {
         this.hauptprobenNr = hauptprobenNr;
     }
+
+    public String getProbeIdAlt() {
+        return this.probeTranslation.getProbeIdAlt();
+    }
+
+    public void setProbeIdAlt(String probeIdAlt) {}
 }
diff -r 248df70de37d -r 76c0cc6d2d85 src/main/java/de/intevation/lada/model/land/ProbeTranslation.java
--- a/src/main/java/de/intevation/lada/model/land/ProbeTranslation.java	Wed Feb 11 12:50:52 2015 +0100
+++ b/src/main/java/de/intevation/lada/model/land/ProbeTranslation.java	Wed Feb 11 12:51:42 2015 +0100
@@ -8,7 +8,19 @@
 package de.intevation.lada.model.land;
 
 import java.io.Serializable;
-import javax.persistence.*;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Generated;
+import org.hibernate.annotations.GenerationTime;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
 
 
 /**
@@ -20,15 +32,15 @@
     private static final long serialVersionUID = 1L;
 
     @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id", unique=true)
     private Integer id;
 
-    @Column(name="hauptproben_nr")
-    private String hauptprobenNr;
+    @OneToOne
+    private LProbe probe;
 
-    @Column(name="probe_id")
-    private Integer probeId;
-
-    @Column(name="probe_id_alt")
+    @Generated(GenerationTime.INSERT)
+    @Column(name="probe_id_alt", insertable=false)
     private String probeIdAlt;
 
     public ProbeTranslation() {
@@ -42,8 +54,13 @@
         this.id = id;
     }
 
+    @JsonIgnore
+    public LProbe getProbeId() {
+        return this.probe;
     }
 
+    public void setProbeId(LProbe probe) {
+        this.probe = probe;
     }
 
     public String getProbeIdAlt() {


More information about the Lada-commits mailing list