Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java @ 3807:d73c43798a99 pre2.6-2011-11-04
merged flys-backend/pre2.6-2011-11-04
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:51 +0200 |
parents | 774dff3ee546 |
children | e9b0fd1de89d |
comparison
equal
deleted
inserted
replaced
3806:881fcd01e056 | 3807:d73c43798a99 |
---|---|
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.MultiPolygon; | |
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 MultiPolygon 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 MultiPolygon getGeom() { | |
61 return geom; | |
62 } | |
63 | |
64 public void setGeom(MultiPolygon 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 : |