changeset 1214:32ee9babe42c

Schema: Argh! Added distance_{vl|hf|vr} to wrong table. flys-backend/trunk@2340 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 15 Jul 2011 15:53:33 +0000
parents cc88db4a5b34
children 8aef353e54fb
files flys-backend/ChangeLog flys-backend/doc/schema/postgresql.sql flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java flys-backend/src/main/java/de/intevation/flys/model/HYKFormation.java
diffstat 4 files changed, 62 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Fri Jul 15 15:36:59 2011 +0000
+++ b/flys-backend/ChangeLog	Fri Jul 15 15:53:33 2011 +0000
@@ -1,3 +1,21 @@
+2011-07-15	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* doc/schema/postgresql.sql: Argh! Added distance_{vl|hf|vr} to
+	  wrong table.
+	  To update existing databases:
+	  BEGIN;
+	    ALTER TABLE hyk_entries DROP COLUMN distance_vl;
+	    ALTER TABLE hyk_entries DROP COLUMN distance_hf;
+	    ALTER TABLE hyk_entries DROP COLUMN distance_vr;
+		ALTER TABLE hyk_formations ADD COLUMN distance_vl NUMERIC NOT NULL;
+		ALTER TABLE hyk_formations ADD COLUMN distance_hf NUMERIC NOT NULL;
+		ALTER TABLE hyk_formations ADD COLUMN distance_vr NUMERIC NOT NULL;
+	  COMMIT;
+
+	* src/main/java/de/intevation/flys/model/HYKFormation.java,
+	  src/main/java/de/intevation/flys/model/HYKEntry.java:
+	  Adjusted Hibernate models.
+
 2011-07-15	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/utils/FileTools.java: Added method
--- a/flys-backend/doc/schema/postgresql.sql	Fri Jul 15 15:36:59 2011 +0000
+++ b/flys-backend/doc/schema/postgresql.sql	Fri Jul 15 15:53:33 2011 +0000
@@ -308,9 +308,6 @@
     id          int PRIMARY KEY NOT NULL,
     hyk_id      int             NOT NULL REFERENCES hyks(id),
     km          NUMERIC         NOT NULL,
-    distance_vl NUMERIC         NOT NULL,
-    distance_hf NUMERIC         NOT NULL,
-    distance_vr NUMERIC         NOT NULL,
     UNIQUE (hyk_id, km)
 );
 
@@ -322,6 +319,9 @@
     hyk_entry_id  int             NOT NULL REFERENCES hyk_entries(id),
     top           NUMERIC         NOT NULL,
     bottom        NUMERIC         NOT NULL,
+    distance_vl   NUMERIC         NOT NULL,
+    distance_hf   NUMERIC         NOT NULL,
+    distance_vr   NUMERIC         NOT NULL,
     UNIQUE (hyk_entry_id, formation_num)
 );
 
--- a/flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java	Fri Jul 15 15:36:59 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java	Fri Jul 15 15:53:33 2011 +0000
@@ -26,27 +26,15 @@
     private Integer    id;
     private HYK        hyk;
     private BigDecimal km;
-    private BigDecimal distanceVL;
-    private BigDecimal distanceHF;
-    private BigDecimal distanceVR;
 
     private List<HYKFormation> formations;
 
     public HYKEntry() {
     }
 
-    public HYKEntry(
-        HYK        hyk,
-        BigDecimal km,
-        BigDecimal distanceVL,
-        BigDecimal distanceHF,
-        BigDecimal distanceVR
-    ) {
-        this.hyk        = hyk;
-        this.km         = km;
-        this.distanceVL = distanceVL;
-        this.distanceHF = distanceHF;
-        this.distanceVR = distanceVR;
+    public HYKEntry(HYK hyk, BigDecimal km) {
+        this.hyk = hyk;
+        this.km  = km;
     }
 
     @Id
@@ -85,33 +73,6 @@
         this.km = km;
     }
 
-    @Column(name = "distance_vl")
-    public BigDecimal getDistanceVL() {
-        return distanceVL;
-    }
-
-    public void setDistanceVL(BigDecimal distanceVL) {
-        this.distanceVL = distanceVL;
-    }
-
-    @Column(name = "distance_hf")
-    public BigDecimal getDistanceHF() {
-        return distanceHF;
-    }
-
-    public void setDistanceHF(BigDecimal distanceHF) {
-        this.distanceHF = distanceHF;
-    }
-
-    @Column(name = "distance_vr")
-    public BigDecimal getDistanceVR() {
-        return distanceVR;
-    }
-
-    public void setDistanceVR(BigDecimal distanceVR) {
-        this.distanceVR = distanceVR;
-    }
-
     @OneToMany
     @OrderBy("formation_num")
     @JoinColumn(name="hyk_entry_id")
--- a/flys-backend/src/main/java/de/intevation/flys/model/HYKFormation.java	Fri Jul 15 15:36:59 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HYKFormation.java	Fri Jul 15 15:53:33 2011 +0000
@@ -28,6 +28,9 @@
     private HYKEntry   entry;
     private BigDecimal top;
     private BigDecimal bottom;
+    private BigDecimal distanceVL;
+    private BigDecimal distanceHF;
+    private BigDecimal distanceVR;
 
     private List<HYKFlowZone> zones;
 
@@ -38,12 +41,18 @@
         Integer    formationNum, 
         HYKEntry   entry, 
         BigDecimal top, 
-        BigDecimal bottom
+        BigDecimal bottom,
+        BigDecimal distanceVL,
+        BigDecimal distanceHF,
+        BigDecimal distanceVR
     ) {
         this.formationNum = formationNum;
         this.entry        = entry;
         this.top          = top;
         this.bottom       = bottom;
+        this.distanceVL   = distanceVL;
+        this.distanceHF   = distanceHF;
+        this.distanceVR   = distanceVR;
     }
 
     @Id
@@ -100,6 +109,34 @@
         this.bottom = bottom;
     }
 
+    @Column(name = "distance_vl")
+    public BigDecimal getDistanceVL() {
+        return distanceVL;
+    }
+
+    public void setDistanceVL(BigDecimal distanceVL) {
+        this.distanceVL = distanceVL;
+    }
+
+    @Column(name = "distance_hf")
+    public BigDecimal getDistanceHF() {
+        return distanceHF;
+    }
+
+    public void setDistanceHF(BigDecimal distanceHF) {
+        this.distanceHF = distanceHF;
+    }
+
+    @Column(name = "distance_vr")
+    public BigDecimal getDistanceVR() {
+        return distanceVR;
+    }
+
+    public void setDistanceVR(BigDecimal distanceVR) {
+        this.distanceVR = distanceVR;
+    }
+
+
     @OneToMany
     @OrderBy("a")
     @JoinColumn(name="formation_id")

http://dive4elements.wald.intevation.org