changeset 447:76c0cc6d2d85

Added one to one realtion.^
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 11 Feb 2015 12:51:42 +0100
parents 248df70de37d
children 4986ef8bff19
files src/main/java/de/intevation/lada/model/land/LProbe.java src/main/java/de/intevation/lada/model/land/ProbeTranslation.java
diffstat 2 files changed, 45 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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) {}
 }
--- 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() {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)