Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/Catchment.java @ 3815:ecab7e7804a9 pre2.6-2012-01-04
merged flys-backend/pre2.6-2012-01-04
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:57 +0200 |
parents | efe19e669092 |
children | bb116a8d6e19 |
comparison
equal
deleted
inserted
replaced
3814:8083f6384023 | 3815:ecab7e7804a9 |
---|---|
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.Polygon; | |
19 | |
20 import de.intevation.flys.backend.SessionHolder; | |
21 | |
22 | |
23 @Entity | |
24 @Table(name = "catchment") | |
25 public class Catchment | |
26 implements Serializable | |
27 { | |
28 private Integer id; | |
29 private BigDecimal area; | |
30 private String name; | |
31 private River river; | |
32 private Polygon geom; | |
33 | |
34 public Catchment() { | |
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 = "name") | |
63 public String getName() { | |
64 return name; | |
65 } | |
66 | |
67 | |
68 public void setName(String name) { | |
69 this.name = name; | |
70 } | |
71 | |
72 | |
73 @Column(name = "area") | |
74 public BigDecimal getArea() { | |
75 return area; | |
76 } | |
77 | |
78 | |
79 public void setArea(BigDecimal area) { | |
80 this.area = area; | |
81 } | |
82 | |
83 | |
84 @Column(name = "geom") | |
85 @Type(type = "org.hibernatespatial.GeometryUserType") | |
86 public Polygon getGeom() { | |
87 return geom; | |
88 } | |
89 | |
90 | |
91 public void setGeom(Polygon geom) { | |
92 this.geom = geom; | |
93 } | |
94 | |
95 | |
96 public static List<Catchment> getCatchments(int riverId) { | |
97 Session session = SessionHolder.HOLDER.get(); | |
98 | |
99 Query query = session.createQuery( | |
100 "from Catchment where river.id =:river_id"); | |
101 query.setParameter("river_id", riverId); | |
102 | |
103 return query.list(); | |
104 } | |
105 } | |
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |