Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/Floodplain.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 | e9b0fd1de89d |
children | 88e3473a3846 |
comparison
equal
deleted
inserted
replaced
2793:6310b1582f2d | 2877:f0a67bc0e777 |
---|---|
1 package de.intevation.flys.model; | |
2 | |
3 import java.io.Serializable; | |
4 import java.util.List; | |
5 | |
6 import javax.persistence.Column; | |
7 import javax.persistence.Entity; | |
8 import javax.persistence.Id; | |
9 import javax.persistence.JoinColumn; | |
10 import javax.persistence.OneToOne; | |
11 import javax.persistence.Table; | |
12 | |
13 import org.hibernate.Query; | |
14 import org.hibernate.Session; | |
15 import org.hibernate.annotations.Type; | |
16 | |
17 import com.vividsolutions.jts.geom.Polygon; | |
18 | |
19 import de.intevation.flys.backend.SessionHolder; | |
20 | |
21 | |
22 @Entity | |
23 @Table(name = "floodplain") | |
24 public class Floodplain | |
25 implements Serializable | |
26 { | |
27 private Integer id; | |
28 | |
29 private River river; | |
30 | |
31 private Polygon geom; | |
32 | |
33 | |
34 public Floodplain() { | |
35 } | |
36 | |
37 | |
38 @Id | |
39 @Column(name = "id") | |
40 public Integer getId() { | |
41 return id; | |
42 } | |
43 | |
44 public void setId(Integer id) { | |
45 this.id = id; | |
46 } | |
47 | |
48 @OneToOne | |
49 @JoinColumn(name = "river_id") | |
50 public River getRiver() { | |
51 return river; | |
52 } | |
53 | |
54 public void setRiver(River river) { | |
55 this.river = river; | |
56 } | |
57 | |
58 @Column(name = "geom") | |
59 @Type(type = "org.hibernatespatial.GeometryUserType") | |
60 public Polygon getGeom() { | |
61 return geom; | |
62 } | |
63 | |
64 public void setGeom(Polygon geom) { | |
65 this.geom = geom; | |
66 } | |
67 | |
68 | |
69 public static Floodplain getFloodplain(String river) { | |
70 Session session = SessionHolder.HOLDER.get(); | |
71 | |
72 Query query = session.createQuery( | |
73 "from Floodplain where river.name =:river"); | |
74 query.setParameter("river", river); | |
75 | |
76 List<Floodplain> result = query.list(); | |
77 | |
78 return result.isEmpty() ? null : result.get(0); | |
79 } | |
80 } | |
81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |