Mercurial > dive4elements > river
changeset 2872:bcfdaa3a5bfc
Added functions to BedHeightSingle and BedHeightEpoch to get instances from db by id or river.
flys-backend/trunk@4434 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 May 2012 07:01:47 +0000 |
parents | 5a89c2b05e6d |
children | 1894e0471eac |
files | flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java |
diffstat | 3 files changed, 68 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/ChangeLog Tue May 15 14:19:55 2012 +0000 +++ b/flys-backend/ChangeLog Fri May 18 07:01:47 2012 +0000 @@ -1,3 +1,9 @@ +2012-05-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/BedHeightEpoch.java, + src/main/java/de/intevation/flys/model/BedHeightSingle.java: Added + functions to get singles and epochs by river and by id. + 2012-05-15 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/model/FlowVelocityModel.java,
--- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java Tue May 15 14:19:55 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java Fri May 18 07:01:47 2012 +0000 @@ -16,6 +16,11 @@ import javax.persistence.OneToOne; import javax.persistence.OneToMany; +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.backend.SessionHolder; + @Entity @Table(name = "bed_height_epoch") @@ -156,5 +161,31 @@ public void setValues(List<BedHeightEpochValue> values) { this.values = values; } + + + public static List<BedHeightEpoch> getBedHeightEpochs(River river) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightEpoch where river=:river"); + + query.setParameter("river", river); + + return query.list(); + } + + + public static BedHeightEpoch getBedHeightEpochById(int id) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightEpoch where id=:id"); + + query.setParameter("id", id); + + List<BedHeightEpoch> singles = query.list(); + + return singles != null ? singles.get(0) : null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java Tue May 15 14:19:55 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java Fri May 18 07:01:47 2012 +0000 @@ -15,6 +15,11 @@ import javax.persistence.OneToOne; import javax.persistence.OneToMany; +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.backend.SessionHolder; + @Entity @Table(name = "bed_height_single") @@ -216,5 +221,31 @@ public void setValues(List<BedHeightSingleValue> values) { this.values = values; } + + + public static List<BedHeightSingle> getBedHeightSingles(River river) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightSingle where river=:river"); + + query.setParameter("river", river); + + return query.list(); + } + + + public static BedHeightSingle getBedHeightSingleById(int id) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from BedHeightSingle where id=:id"); + + query.setParameter("id", id); + + List<BedHeightSingle> singles = query.list(); + + return singles != null ? singles.get(0) : null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :