Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpochValue.java @ 2877:f0a67bc0e777 2.7
merged flys-backend/2.7
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:31 +0200 |
parents | 1894e0471eac |
children |
comparison
equal
deleted
inserted
replaced
2793:6310b1582f2d | 2877:f0a67bc0e777 |
---|---|
1 package de.intevation.flys.model; | |
2 | |
3 import java.util.List; | |
4 | |
5 import java.io.Serializable; | |
6 import java.math.BigDecimal; | |
7 | |
8 import javax.persistence.Entity; | |
9 import javax.persistence.Id; | |
10 import javax.persistence.Table; | |
11 import javax.persistence.GeneratedValue; | |
12 import javax.persistence.Column; | |
13 import javax.persistence.SequenceGenerator; | |
14 import javax.persistence.GenerationType; | |
15 import javax.persistence.JoinColumn; | |
16 import javax.persistence.OneToOne; | |
17 | |
18 import org.apache.log4j.Logger; | |
19 | |
20 import org.hibernate.Session; | |
21 import org.hibernate.Query; | |
22 | |
23 import de.intevation.flys.backend.SessionHolder; | |
24 | |
25 | |
26 @Entity | |
27 @Table(name = "bed_height_epoch_values") | |
28 public class BedHeightEpochValue | |
29 implements Serializable | |
30 { | |
31 private static Logger logger = | |
32 Logger.getLogger(BedHeightEpochValue.class); | |
33 | |
34 private Integer id; | |
35 | |
36 private BedHeightEpoch bedHeight; | |
37 | |
38 private BigDecimal station; | |
39 private BigDecimal height; | |
40 | |
41 | |
42 public BedHeightEpochValue() { | |
43 } | |
44 | |
45 public BedHeightEpochValue( | |
46 BedHeightEpoch bedHeight, | |
47 BigDecimal station, | |
48 BigDecimal height | |
49 ) { | |
50 this.bedHeight = bedHeight; | |
51 this.station = station; | |
52 this.height = height; | |
53 } | |
54 | |
55 @Id | |
56 @SequenceGenerator( | |
57 name = "SEQUENCE_BED_EPOCH_VALUE_ID_SEQ", | |
58 sequenceName = "BED_EPOCH_VALUES_ID_SEQ", | |
59 allocationSize = 1) | |
60 @GeneratedValue( | |
61 strategy = GenerationType.SEQUENCE, | |
62 generator = "SEQUENCE_BED_EPOCH_VALUE_ID_SEQ") | |
63 @Column(name = "id") | |
64 public Integer getId() { | |
65 return id; | |
66 } | |
67 | |
68 public void setId(Integer id) { | |
69 this.id = id; | |
70 } | |
71 | |
72 @OneToOne | |
73 @JoinColumn(name = "bed_height_epoch_id" ) | |
74 public BedHeightEpoch getBedHeight() { | |
75 return bedHeight; | |
76 } | |
77 | |
78 public void setBedHeight(BedHeightEpoch bedHeight) { | |
79 this.bedHeight = bedHeight; | |
80 } | |
81 | |
82 @Column(name = "station") | |
83 public BigDecimal getStation() { | |
84 return station; | |
85 } | |
86 | |
87 public void setStation(BigDecimal station) { | |
88 this.station = station; | |
89 } | |
90 | |
91 @Column(name = "height") | |
92 public BigDecimal getHeight() { | |
93 return height; | |
94 } | |
95 | |
96 public void setHeight(BigDecimal height) { | |
97 this.height = height; | |
98 } | |
99 | |
100 | |
101 public static List<BedHeightEpochValue> getBedHeightEpochValues( | |
102 BedHeightEpoch epoch, | |
103 double kmLo, | |
104 double kmHi | |
105 ) { | |
106 Session session = SessionHolder.HOLDER.get(); | |
107 | |
108 Query query = session.createQuery( | |
109 "from BedHeightEpochValue where bedHeight=:epoch " + | |
110 " and station >= :kmLo and station <= :kmHi"); | |
111 | |
112 query.setParameter("epoch", epoch); | |
113 query.setParameter("kmLo", new BigDecimal(kmLo)); | |
114 query.setParameter("kmHi", new BigDecimal(kmHi)); | |
115 | |
116 return query.list(); | |
117 } | |
118 } | |
119 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |