changeset 8102:28816abe7d5c

Add getSedimentLoadById accessor
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 20 Aug 2014 12:00:50 +0200
parents 54dfdba4c4c5
children 54d35418141e
files backend/src/main/java/org/dive4elements/river/model/SedimentLoadLS.java
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/SedimentLoadLS.java	Tue Aug 19 18:46:13 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/SedimentLoadLS.java	Wed Aug 20 12:00:50 2014 +0200
@@ -22,6 +22,9 @@
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
 
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.dive4elements.river.backend.SessionHolder;
 
 /** SedimentLoadLS of a certain Fraction with possibly many values. */
 @Entity
@@ -181,5 +184,18 @@
     public void setSedimentLoadLSValues(List<SedimentLoadLSValue> values) {
         this.values = values;
     }
+
+    public static SedimentLoadLS getSedimentLoadById(int id) {
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from SedimentLoadLS where id=:db_id");
+
+        query.setParameter("db_id", id);
+
+        List<SedimentLoadLS> results = query.list();
+
+        return results.isEmpty() ? null : results.get(0);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org