Added Funcs.countStar() because it's such a common SQL operation.
This commit is contained in:
@@ -53,6 +53,15 @@ public class Funcs
|
||||
return new Average<Number>(expr, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an aggregate expression that counts the number of rows that match the other clauses
|
||||
* in this query.
|
||||
*/
|
||||
public static FluentExp<Integer> countStar ()
|
||||
{
|
||||
return new Count(Exps.literal("*"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an aggregate expression that counts the number of rows from the supplied
|
||||
* expression. This would usually be used in a FieldOverride and supplied with a ColumnExp.
|
||||
|
||||
@@ -373,7 +373,7 @@ public class Query<T extends PersistentRecord>
|
||||
*/
|
||||
public int selectCount ()
|
||||
{
|
||||
checkState(_groupBy == null, "Do you mean to select(Funcs.count(Exps.literal(\"*\")))?");
|
||||
checkState(_groupBy == null, "Do you mean to select(Funcs.countStar())?");
|
||||
_fromOverride = new FromOverride(_pclass);
|
||||
return _repo.load(CountRecord.class, _cache, getClauseArray()).count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user