From: Kazunobu Raita Date: Sat, 22 Feb 2014 08:32:07 +0000 (+0900) Subject: Fix a bug and limit 1 select when select first X-Git-Tag: v1.3.0~18^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8fc18480283d9f9d8d4a82e7220a2b870bfa083f;p=iciql.git Fix a bug and limit 1 select when select first --- diff --git a/src/main/java/com/iciql/Query.java b/src/main/java/com/iciql/Query.java index 5dc78a5..45de08b 100644 --- a/src/main/java/com/iciql/Query.java +++ b/src/main/java/com/iciql/Query.java @@ -95,7 +95,8 @@ public class Query { } public T selectFirst() { - return select(false).get(0); + List list = limit(1).select(false); + return list.isEmpty() ? null : list.get(0); } public List selectDistinct() { @@ -104,7 +105,7 @@ public class Query { @SuppressWarnings("unchecked") public X selectFirst(Z x) { - List list = (List) select(x); + List list = limit(1).select(x); return list.isEmpty() ? null : list.get(0); }