diff options
Diffstat (limited to 'src/main/java/com/iciql')
-rw-r--r-- | src/main/java/com/iciql/Query.java | 5 |
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);
}
|