# HG changeset patch # User Tom Gottfried # Date 1417115738 -3600 # Node ID 0c22ef71d1540c4d003aac47b422e0610e274146 # Parent 7dd39219bd68f9311c7054c02ca1b90a7367210e Use explicit query to avoid hibernate connection leak. diff -r 7dd39219bd68 -r 0c22ef71d154 backend/src/main/java/org/dive4elements/river/model/Gauge.java --- a/backend/src/main/java/org/dive4elements/river/model/Gauge.java Thu Nov 27 19:55:55 2014 +0100 +++ b/backend/src/main/java/org/dive4elements/river/model/Gauge.java Thu Nov 27 20:15:38 2014 +0100 @@ -178,15 +178,7 @@ public double[] determineMinMaxW() { Session session = SessionHolder.HOLDER.get(); - List tables = getDischargeTables(); - DischargeTable dischargeTable = null; - - for (DischargeTable tmp: tables) { - if (tmp.getKind() == 0) { - dischargeTable = tmp; - break; - } - } + DischargeTable dischargeTable = fetchMasterDischargeTable(); if (dischargeTable == null) { return null; @@ -253,13 +245,20 @@ public DischargeTable fetchMasterDischargeTable() { - for (DischargeTable dt: dischargeTables) { - if (dt.getKind() == MASTER_DISCHARGE_TABLE) { - return dt; - } - } + Session session = SessionHolder.HOLDER.get(); - return null; + Query query = session.createQuery( + "from DischargeTable " + + "where kind = 0 " + + "and gauge = :gauge"); + + query.setParameter("gauge", this); + + List results = query.list(); + + return results.isEmpty() + ? null + : (DischargeTable)results.get(0); } /**