we want to use the spring-batch-admin on WAS70 with DB2-Database underlying.
The list of executions is delimited to 20 per default. If we try to jump on the next page, an internal server error 500 will occur.
As we hit the "next" button, the method generateJumpToItemQuery(int itemIndex, int pageSize) in org.springframework.batch.item.database.support.Db2PagingQueryProvider is called.
The generated SQL-Statement is:
SELECT E.JOB_EXECUTION_ID FROM ( SELECT E.JOB_EXECUTION_ID, ROW_NUMBER() OVER ( ORDER BY E.JOB_EXECUTION_ID DESC) AS ROW_NUMBER FROM T1100Z.BATCH_JOB_EXECUTION E, T1100Z.BATCH_JOB_INSTANCE I WHERE E.JOB_INSTANCE_ID=I.JOB_INSTANCE_ID) AS TMP_SUB WHERE TMP_SUB.ROW_NUMBER = 20 ORDER BY E.JOB_EXECUTION_ID DESC
After a few test i found out the right SQL:
SELECT TMP_SUB.JOB_EXECUTION_ID FROM ( SELECT E.JOB_EXECUTION_ID, ROW_NUMBER() OVER ( ORDER BY E.JOB_EXECUTION_ID DESC) AS ROW_NUMBER FROM T1100Z.BATCH_JOB_EXECUTION E, T1100Z.BATCH_JOB_INSTANCE I WHERE E.JOB_INSTANCE_ID=I.JOB_INSTANCE_ID) AS TMP_SUB WHERE TMP_SUB.ROW_NUMBER = 20 ORDER BY TMP_SUB.JOB_EXECUTION_ID DESC
As you can see, the subquery uses the "E.", but comes out as TMP_SUB.
The "E." is set by the batch-admin-manager: sortKeys.put("E.JOB_EXECUTION_ID", Order.DESCENDING);
I think a the generateJumpToItemQuery-Method in Db2PagingQueryProvider has to be overridden, or the method buildSortKeySelect(StringBuilder sql) could get a brother like: buildSortKeySelect(StringBuilder sql, String qualifierReplacement) ("E." -> "TMP_SUB.")
Spring Batch Admin hasn't been updated to work with 2.2 officially yet. There are a couple breaking changes within 2.2 that will impact it's use with Admin. The nightly release should be close but even that isn't 100% tested yet (this issue is in the nightly build as well). I think this issue can be addressed in admin without a change to batch by aliasing the field with a unique name, thereby not requiring the table alias at all.
Can you submit a pull request with this change in Github? Please be sure to fill out a contributor's agreement.
Without changing anything in batch, i fixed the issue by setting the sortkeys without "E.": sortKeys.put("JOB_EXECUTION_ID", Order.DESCENDING);. I think this could fix the issue without any aliasing because the column name (JOB_EXECUTION_ID) is already unique for this sql-statement.