comparison flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.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 22eea1c9e907
children 61cb16549eb1
comparison
equal deleted inserted replaced
3814:8083f6384023 3815:ecab7e7804a9
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.LineString;
18
19 import de.intevation.flys.backend.SessionHolder;
20
21
22 @Entity
23 @Table(name = "river_axes")
24 public class RiverAxis
25 implements Serializable
26 {
27 private Integer id;
28 private Integer kind;
29 private River river;
30 private LineString geom;
31
32 public RiverAxis() {
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 = "kind")
61 public Integer getKind() {
62 return kind;
63 }
64
65
66 public void setKind(Integer kind) {
67 this.kind = kind;
68 }
69
70
71 @Column(name = "geom")
72 @Type(type = "org.hibernatespatial.GeometryUserType")
73 public LineString getGeom() {
74 return geom;
75 }
76
77
78 public void setGeom(LineString geom) {
79 this.geom = geom;
80 }
81
82
83 public static RiverAxis getRiverAxis(String river) {
84 Session session = SessionHolder.HOLDER.get();
85
86 Query query = session.createQuery(
87 "from RiverAxis where river.name =:river");
88 query.setParameter("river", river);
89
90 List<RiverAxis> list = query.list();
91
92 return list.isEmpty() ? null : list.get(0);
93 }
94 }
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org