comparison flys-backend/src/main/java/de/intevation/flys/model/RiverAxisKm.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 9df06b88c079
children
comparison
equal deleted inserted replaced
2793:6310b1582f2d 2877:f0a67bc0e777
1 package de.intevation.flys.model;
2
3 import java.io.Serializable;
4 import java.math.BigDecimal;
5 import java.util.List;
6
7 import javax.persistence.Column;
8 import javax.persistence.Entity;
9 import javax.persistence.Id;
10 import javax.persistence.JoinColumn;
11 import javax.persistence.OneToOne;
12 import javax.persistence.Table;
13
14 import org.hibernate.Session;
15 import org.hibernate.Query;
16 import org.hibernate.annotations.Type;
17
18 import com.vividsolutions.jts.geom.Point;
19
20 import de.intevation.flys.backend.SessionHolder;
21
22
23 @Entity
24 @Table(name = "river_axes_km")
25 public class RiverAxisKm
26 implements Serializable
27 {
28 private Integer id;
29 private River river;
30 private BigDecimal km;
31 private Point geom;
32
33
34 public RiverAxisKm() {
35 }
36
37
38 @Id
39 @Column(name = "id")
40 public Integer getId() {
41 return id;
42 }
43
44
45 public void setId(Integer id) {
46 this.id = id;
47 }
48
49
50 @OneToOne
51 @JoinColumn(name = "river_id")
52 public River getRiver() {
53 return river;
54 }
55
56
57 public void setRiver(River river) {
58 this.river = river;
59 }
60
61
62 @Column(name = "km")
63 public BigDecimal getKm() {
64 return km;
65 }
66
67
68 public void setKm(BigDecimal km) {
69 this.km = km;
70 }
71
72
73 @Column(name = "geom")
74 @Type(type = "org.hibernatespatial.GeometryUserType")
75 public Point getGeom() {
76 return geom;
77 }
78
79
80 public void setGeom(Point geom) {
81 this.geom = geom;
82 }
83
84
85 /**
86 * Returns a list of RiverAxisKm objects for a given river.
87 *
88 * @param riverid The ID of a river in the database.
89 *
90 * @return a list of RiverAxisKm objects.
91 */
92 public static List<RiverAxisKm> getRiverAxisKms(int riverid) {
93 Session session = SessionHolder.HOLDER.get();
94
95 Query query = session.createQuery(
96 "from RiverAxisKm where river.id =:riverid");
97 query.setParameter("riverid", riverid);
98
99 List<RiverAxisKm> list = query.list();
100
101 return list;
102 }
103 }
104 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org