]> source.dussan.org Git - iciql.git/commitdiff
Fix a bug and limit 1 select when select first 5/head
authorKazunobu Raita <raita_kazunobu@cyberagent.co.jp>
Sat, 22 Feb 2014 08:32:07 +0000 (17:32 +0900)
committerKazunobu Raita <raita_kazunobu@cyberagent.co.jp>
Sat, 22 Feb 2014 08:32:07 +0000 (17:32 +0900)
src/main/java/com/iciql/Query.java

index 5dc78a5db5abccb12884b015610893de1d024bf5..45de08b414aa793187cd63dc69fc3650ffdf1e83 100644 (file)
@@ -95,7 +95,8 @@ public class Query<T> {
        }\r
 \r
        public T selectFirst() {\r
-               return select(false).get(0);\r
+               List<T> list = limit(1).select(false);\r
+               return list.isEmpty() ? null : list.get(0);\r
        }\r
 \r
        public List<T> selectDistinct() {\r
@@ -104,7 +105,7 @@ public class Query<T> {
 \r
        @SuppressWarnings("unchecked")\r
        public <X, Z> X selectFirst(Z x) {\r
-               List<X> list = (List<X>) select(x);\r
+               List<X> list = limit(1).select(x);\r
                return list.isEmpty() ? null : list.get(0);\r
        }\r
        \r