I have a batch job that I am testing with in-memory H2 database. I have a reader that works perfectly fine with a database installed on my computer. But when I test it using H2, I get this error:
org.springframework.jdbc.BadSqlGrammarException: Attempt to process next row failed; bad SQL grammar [select name, age, status, COUNT(STATUS) from myTable]; nested exception is org.h2.jdbc.JdbcSQLException: Column "COUNT(status)" not found [42122-197]
This is my reader. I don't know why I am getting above error.
JdbcCursorItemReader<myObject> reader = new JdbcCursorItemReader<>();
reader.setSql("select name, age, status, COUNT(STATUS) from myTable
where name="something",
group by name, age, status
order by name, age, status);