Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/SedimentLoadLS.java @ 8102:28816abe7d5c
Add getSedimentLoadById accessor
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 20 Aug 2014 12:00:50 +0200 |
parents | 3ae11daff343 |
children | 9b295cc828c5 |
comparison
equal
deleted
inserted
replaced
8101:54dfdba4c4c5 | 8102:28816abe7d5c |
---|---|
20 import javax.persistence.SequenceGenerator; | 20 import javax.persistence.SequenceGenerator; |
21 import javax.persistence.GenerationType; | 21 import javax.persistence.GenerationType; |
22 import javax.persistence.JoinColumn; | 22 import javax.persistence.JoinColumn; |
23 import javax.persistence.OneToOne; | 23 import javax.persistence.OneToOne; |
24 | 24 |
25 import org.hibernate.Session; | |
26 import org.hibernate.Query; | |
27 import org.dive4elements.river.backend.SessionHolder; | |
25 | 28 |
26 /** SedimentLoadLS of a certain Fraction with possibly many values. */ | 29 /** SedimentLoadLS of a certain Fraction with possibly many values. */ |
27 @Entity | 30 @Entity |
28 @Table(name = "sediment_load_ls") | 31 @Table(name = "sediment_load_ls") |
29 public class SedimentLoadLS | 32 public class SedimentLoadLS |
179 } | 182 } |
180 | 183 |
181 public void setSedimentLoadLSValues(List<SedimentLoadLSValue> values) { | 184 public void setSedimentLoadLSValues(List<SedimentLoadLSValue> values) { |
182 this.values = values; | 185 this.values = values; |
183 } | 186 } |
187 | |
188 public static SedimentLoadLS getSedimentLoadById(int id) { | |
189 Session session = SessionHolder.HOLDER.get(); | |
190 | |
191 Query query = session.createQuery( | |
192 "from SedimentLoadLS where id=:db_id"); | |
193 | |
194 query.setParameter("db_id", id); | |
195 | |
196 List<SedimentLoadLS> results = query.list(); | |
197 | |
198 return results.isEmpty() ? null : results.get(0); | |
199 } | |
184 } | 200 } |
185 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 201 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |