From 8fc18480283d9f9d8d4a82e7220a2b870bfa083f Mon Sep 17 00:00:00 2001 From: Kazunobu Raita Date: Sat, 22 Feb 2014 17:32:07 +0900 Subject: [PATCH] Fix a bug and limit 1 select when select first --- src/main/java/com/iciql/Query.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); } -- 2.39.5