aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKazunobu Raita <raita_kazunobu@cyberagent.co.jp>2014-02-22 17:32:07 +0900
committerKazunobu Raita <raita_kazunobu@cyberagent.co.jp>2014-02-22 17:32:07 +0900
commit8fc18480283d9f9d8d4a82e7220a2b870bfa083f (patch)
tree0a42fb9b6165395bb70f6797fa6aec4c3330637b /src
parent6d8ccd40654d877435dabbc879b59bc91dcc74ba (diff)
downloadiciql-8fc18480283d9f9d8d4a82e7220a2b870bfa083f.tar.gz
iciql-8fc18480283d9f9d8d4a82e7220a2b870bfa083f.zip
Fix a bug and limit 1 select when select first
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/iciql/Query.java5
1 files 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<T> {
}
public T selectFirst() {
- return select(false).get(0);
+ List<T> list = limit(1).select(false);
+ return list.isEmpty() ? null : list.get(0);
}
public List<T> selectDistinct() {
@@ -104,7 +105,7 @@ public class Query<T> {
@SuppressWarnings("unchecked")
public <X, Z> X selectFirst(Z x) {
- List<X> list = (List<X>) select(x);
+ List<X> list = limit(1).select(x);
return list.isEmpty() ? null : list.get(0);
}