comparison flys-backend/src/main/java/de/intevation/flys/model/HydrBoundaryPoly.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 b6f94c5db89e
children bafc655ee630
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.Session;
14 import org.hibernate.Query;
15 import org.hibernate.annotations.Type;
16
17 import com.vividsolutions.jts.geom.Geometry;
18
19 import de.intevation.flys.backend.SessionHolder;
20
21
22 @Entity
23 @Table(name = "hydr_boundaries_poly")
24 public class HydrBoundaryPoly
25 implements Serializable
26 {
27 private Integer id;
28 private String name;
29 private River river;
30 private Geometry geom;
31
32 public HydrBoundaryPoly() {
33 }
34
35
36 @Id
37 @Column(name = "id")
38 public Integer getId() {
39 return id;
40 }
41
42
43 public void setId(Integer id) {
44 this.id = id;
45 }
46
47
48 @OneToOne
49 @JoinColumn(name = "river_id")
50 public River getRiver() {
51 return river;
52 }
53
54
55 public void setRiver(River river) {
56 this.river = river;
57 }
58
59
60 @Column(name = "name")
61 public String getName() {
62 return name;
63 }
64
65
66 public void setName(String name) {
67 this.name = name;
68 }
69
70
71 @Column(name = "geom")
72 @Type(type = "org.hibernatespatial.GeometryUserType")
73 public Geometry getGeom() {
74 return geom;
75 }
76
77
78 public void setGeom(Geometry geom) {
79 this.geom = geom;
80 }
81
82
83 public static List<HydrBoundaryPoly> getHydrBoundaries(int riverId, String name) {
84 Session session = SessionHolder.HOLDER.get();
85
86 Query query = session.createQuery(
87 "from HydrBoundaryPoly where river.id =:river_id and name=:name");
88 query.setParameter("river_id", riverId);
89 query.setParameter("name", name);
90
91 return query.list();
92 }
93 }
94 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org