# HG changeset patch # User Andre Heinecke # Date 1408528850 -7200 # Node ID 28816abe7d5c5003933236a452624b8fea39372e # Parent 54dfdba4c4c5ea7c279986a648a7bd0a28e0e592 Add getSedimentLoadById accessor diff -r 54dfdba4c4c5 -r 28816abe7d5c backend/src/main/java/org/dive4elements/river/model/SedimentLoadLS.java --- 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 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 results = query.list(); + + return results.isEmpty() ? null : results.get(0); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :