|
20 | 20 |
|
21 | 21 | import org.flowable.common.engine.api.FlowableException;
|
22 | 22 | import org.flowable.common.engine.api.FlowableIllegalArgumentException;
|
| 23 | +import org.flowable.common.engine.impl.AbstractEngineConfiguration; |
23 | 24 | import org.flowable.engine.impl.test.PluggableFlowableTestCase;
|
24 | 25 | import org.flowable.idm.api.Group;
|
25 | 26 | import org.flowable.idm.api.GroupQuery;
|
@@ -258,4 +259,27 @@ public void testNativeQuery() {
|
258 | 259 | assertThat(identityService.createNativeGroupQuery().sql(baseQuerySql + " where ID_ = #{id}").parameter("id", "admin").listPage(0, 1)).hasSize(1);
|
259 | 260 | }
|
260 | 261 |
|
| 262 | + @Test |
| 263 | + public void testNativeQueryOrder() { |
| 264 | + StringBuilder baseQueryBuilder = new StringBuilder(); |
| 265 | + baseQueryBuilder.append("SELECT "); |
| 266 | + if (AbstractEngineConfiguration.DATABASE_TYPE_MSSQL.equals(processEngineConfiguration.getDatabaseType())) { |
| 267 | + baseQueryBuilder.append("top 100 percent "); |
| 268 | + } |
| 269 | + baseQueryBuilder.append("* FROM ") |
| 270 | + .append(IdentityTestUtil.getTableName("ACT_ID_GROUP", processEngineConfiguration)) |
| 271 | + .append(" order by ID_ desc"); |
| 272 | + String baseQuerySql = baseQueryBuilder.toString(); |
| 273 | + |
| 274 | + assertThat(identityService.createNativeGroupQuery().sql(baseQuerySql).list()) |
| 275 | + .extracting(Group::getId) |
| 276 | + .containsExactly("muppets", "mammals", "frogs", "admin"); |
| 277 | + |
| 278 | + assertThat(identityService.createNativeGroupQuery().sql(baseQuerySql) |
| 279 | + .parameter("orderBy", "ID_ desc") |
| 280 | + .listPage(0, 2)) |
| 281 | + .extracting(Group::getId) |
| 282 | + .containsExactly("muppets", "mammals"); |
| 283 | + } |
| 284 | + |
261 | 285 | }
|
0 commit comments