Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/model/Gauge.java @ 2381:aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
flys-backend/trunk@3702 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 18 Jan 2012 09:26:54 +0000 |
parents | fe89d6cf55fb |
children | 83abe19d4f40 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/model/Gauge.java Tue Jan 17 16:56:38 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/Gauge.java Wed Jan 18 09:26:54 2012 +0000 @@ -213,6 +213,20 @@ public void setMainValues(List<MainValue> mainValues) { this.mainValues = mainValues; - } + } + + + public static Gauge getGaugeByOfficialNumber(long number) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from Gauge where officialNumber=:number"); + + query.setParameter("number", number); + + List<Gauge> results = query.list(); + + return results.isEmpty() ? null : results.get(0); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :