[PATCH 3 of 4] issue1891: Add method to get a discharge table by it's id
Wald Commits
scm-commit at wald.intevation.org
Mon Jul 29 12:20:25 CEST 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1375093031 -7200
# Node ID ce691d22cee3696aaa87002d5c62ca39e29aa5de
# Parent f41ba63e7a434329b64d698ecb157f9d43d89ace
issue1891: Add method to get a discharge table by it's id
diff -r f41ba63e7a43 -r ce691d22cee3 backend/src/main/java/org/dive4elements/river/model/DischargeTable.java
--- 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 :
More information about the Dive4elements-commits
mailing list