File tree Expand file tree Collapse file tree
main/java/org/apache/cayenne/query
test/java/org/apache/cayenne/query Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ CAY-2897 Add no-op default implementations to the GraphChangeHandler interface
1919
2020Bug Fixes:
2121
22+ CAY-2836 ObjectSelect.selectCount() throws if a query contains ordering
2223CAY-2883 License and notice templates are not processed by the Gradle build
2324CAY-2885 Modeler: DbImport fails to load DB schema view
2425CAY-2887 Expressions: Incorrect serialization to string of numeric literals
Original file line number Diff line number Diff line change @@ -678,7 +678,10 @@ public ObjectSelect<T> distinct() {
678678 * @return count of rows
679679 */
680680 public long selectCount (ObjectContext context ) {
681- return count ().selectOne (context );
681+ ColumnSelect <Long > count = count ();
682+ // reset orderings, see CAY-2836
683+ count .orderings = Collections .emptyList ();
684+ return count .selectOne (context );
682685 }
683686
684687 @ Override
Original file line number Diff line number Diff line change @@ -236,4 +236,12 @@ public void test_CAY_2092() {
236236 assertNotNull (artist );
237237 }
238238 }
239+
240+ @ Test
241+ public void test_CAY_2836_countWithOrdering () {
242+ long count = ObjectSelect .query (Artist .class )
243+ .orderBy (Artist .ARTIST_NAME .asc ())
244+ .selectCount (context );
245+ assertEquals (20 , count );
246+ }
239247}
You can’t perform that action at this time.
0 commit comments