Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/NamedMainValue.java @ 6355:d6ae01d6a7cb
Backend: Added one to many getter to fetch the official lines associated with a namend main value.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 17 Jun 2013 21:49:31 +0200 |
parents | bc28de00e423 |
children | 5910ada51a9f |
comparison
equal
deleted
inserted
replaced
6354:626af4af74a5 | 6355:d6ae01d6a7cb |
---|---|
11 import java.io.Serializable; | 11 import java.io.Serializable; |
12 import java.util.List; | 12 import java.util.List; |
13 | 13 |
14 import javax.persistence.Entity; | 14 import javax.persistence.Entity; |
15 import javax.persistence.Id; | 15 import javax.persistence.Id; |
16 import javax.persistence.OneToMany; | |
16 import javax.persistence.Table; | 17 import javax.persistence.Table; |
17 import javax.persistence.GeneratedValue; | 18 import javax.persistence.GeneratedValue; |
18 import javax.persistence.Column; | 19 import javax.persistence.Column; |
19 import javax.persistence.SequenceGenerator; | 20 import javax.persistence.SequenceGenerator; |
20 import javax.persistence.GenerationType; | 21 import javax.persistence.GenerationType; |
30 implements Serializable | 31 implements Serializable |
31 { | 32 { |
32 private Integer id; | 33 private Integer id; |
33 private String name; | 34 private String name; |
34 private MainValueType type; | 35 private MainValueType type; |
36 | |
37 private List<OfficialLine> officialLines; | |
35 | 38 |
36 public NamedMainValue() { | 39 public NamedMainValue() { |
37 } | 40 } |
38 | 41 |
39 public NamedMainValue(String name, MainValueType type) { | 42 public NamedMainValue(String name, MainValueType type) { |
75 | 78 |
76 public void setType(MainValueType type) { | 79 public void setType(MainValueType type) { |
77 this.type = type; | 80 this.type = type; |
78 } | 81 } |
79 | 82 |
83 @OneToMany | |
84 @JoinColumn(name = "named_main_value_id") | |
85 public List<OfficialLine> getOfficialLines() { | |
86 return officialLines; | |
87 } | |
88 | |
89 public void setOfficialLines(List<OfficialLine> officialLines) { | |
90 this.officialLines = officialLines; | |
91 } | |
92 | |
80 public static NamedMainValue fetchByName(String name, Session session) { | 93 public static NamedMainValue fetchByName(String name, Session session) { |
81 Query query = session.createQuery( | 94 Query query = session.createQuery( |
82 "from NamedMainValue where name=:name"); | 95 "from NamedMainValue where name=:name"); |
83 query.setString("name", name); | 96 query.setString("name", name); |
84 List<NamedMainValue> named = query.list(); | 97 List<NamedMainValue> named = query.list(); |