Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstFactory.java @ 318:8a4360ccbe1c
Added a WstFactory to return Wst objects.
flys-artifacts/trunk@1706 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 15 Apr 2011 13:46:22 +0000 |
parents | |
children | 02ca2ff96dee |
comparison
equal
deleted
inserted
replaced
317:8f40a57229c3 | 318:8a4360ccbe1c |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.util.List; | |
4 | |
5 import de.intevation.flys.backend.SessionHolder; | |
6 import de.intevation.flys.model.River; | |
7 import de.intevation.flys.model.Wst; | |
8 | |
9 import org.hibernate.Query; | |
10 import org.hibernate.Session; | |
11 | |
12 /** | |
13 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
14 */ | |
15 public class WstFactory { | |
16 | |
17 /** We don't need to instantiate concrete objects of this class. */ | |
18 private WstFactory() { | |
19 } | |
20 | |
21 | |
22 /** | |
23 * Returns the Wst object for a given river. | |
24 * | |
25 * @param river The river. | |
26 * | |
27 * @return the Wst of <i>river</i>. | |
28 */ | |
29 public static Wst getWst(River river) { | |
30 Session session = SessionHolder.HOLDER.get(); | |
31 | |
32 Query query = session.createQuery( | |
33 "from Wst where river=:river"); | |
34 query.setParameter("river", river); | |
35 | |
36 List<Wst> wst = query.list(); | |
37 | |
38 return (wst != null && wst.size() > 0) ? wst.get(0) : null; | |
39 } | |
40 } | |
41 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |