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