changeset 6692:ce691d22cee3

issue1891: Add method to get a discharge table by it's id
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 29 Jul 2013 12:17:11 +0200
parents f41ba63e7a43
children 88bb0c794833
files backend/src/main/java/org/dive4elements/river/model/DischargeTable.java
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/DischargeTable.java	Mon Jul 29 12:16:12 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/DischargeTable.java	Mon Jul 29 12:17:11 2013 +0200
@@ -24,6 +24,10 @@
 import javax.persistence.SequenceGenerator;
 import javax.persistence.Table;
 
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.dive4elements.river.backend.SessionHolder;
+
 @Entity
 @Table(name = "discharge_tables")
 public class DischargeTable
@@ -197,5 +201,16 @@
             return 0;
         }
     }
+
+    public static DischargeTable getDischargeTableById(int dtId)
+    {
+        Session session = SessionHolder.HOLDER.get();
+        Query query = session.createQuery(
+            "from DischargeTable where id =:dtId");
+        query.setParameter("dtId", dtId);
+
+        List<DischargeTable> list = query.list();
+        return list.isEmpty() ? null : list.get(0);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org