diff flys-backend/src/main/java/de/intevation/flys/model/Wst.java @ 469:b5ca22aae092

Fixed index problem when an empty list is returned. flys-backend/trunk@1708 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 15 Apr 2011 14:30:54 +0000
parents 8d76556c9616
children 9aa0eddc5221
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/model/Wst.java	Fri Apr 15 13:45:06 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Wst.java	Fri Apr 15 14:30:54 2011 +0000
@@ -126,18 +126,21 @@
           " and range.id in " +
           "  (select id from Range where not (a > :end or b < :start))");
 
-        query.setParameter("wst", getId());
+        query.setParameter("wst",   getId());
         query.setParameter("start", range.getA());
-        query.setParameter("end", range.getB());
+        query.setParameter("end",   range.getB());
 
-        List     results = query.list();
-        Object[] result  = (Object[]) results.get(0);
+        List<Object []> results = query.list();
 
-        return result != null
-            ? new double[] {
-                ((BigDecimal) result[0]).doubleValue(),
-                ((BigDecimal) result[1]).doubleValue() }
-            : null;
+        if (results.isEmpty()) {
+            return null;
+        }
+
+        Object [] result = results.get(0);
+
+        return new double [] {
+            ((BigDecimal)result[0]).doubleValue(),
+            ((BigDecimal)result[1]).doubleValue() };
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org