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 @@ -22,6 +22,7 @@ CAY-2897 Add no-op default implementations to the GraphChangeHandler interface
2222Bug Fixes:
2323
2424CAY-2701 MySQL DST-related LocalDateTime issues
25+ CAY-2836 ObjectSelect.selectCount() throws if a query contains ordering
2526CAY-2871 QualifierTranslator breaks on a relationship with a compound FK
2627CAY-2872 CayenneModeler "Documentation" link is broken
2728CAY-2876 Memory leak in the ObjectStore
Original file line number Diff line number Diff line change @@ -328,7 +328,10 @@ public ObjectSelect<T> distinct() {
328328 * @return count of rows
329329 */
330330 public long selectCount (ObjectContext context ) {
331- return count ().selectOne (context );
331+ ColumnSelect <Long > count = count ();
332+ // reset orderings, see CAY-2836
333+ count .orderings = List .of ();
334+ return count .selectOne (context );
332335 }
333336
334337 @ Override
Original file line number Diff line number Diff line change @@ -246,4 +246,12 @@ public void test_CAY_2092() {
246246 assertNotNull (artist );
247247 }
248248 }
249+
250+ @ Test
251+ public void test_CAY_2836_countWithOrdering () {
252+ long count = ObjectSelect .query (Artist .class )
253+ .orderBy (Artist .ARTIST_NAME .asc ())
254+ .selectCount (context );
255+ assertEquals (20 , count );
256+ }
249257}
You can’t perform that action at this time.
0 commit comments