PDA

View Full Version : Error when saving a StepInstance



gpitteloud
Feb 18th, 2008, 06:59 AM
I am facing a blocking issue when saving a step instance/step execution.

Here is the error stack:


Caused by: java.sql.SQLException: Invalid column datatype
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:269)
at oracle.jdbc.driver.OracleStatement.get_internal_ty pe(OracleStatement.java:6541)
at oracle.jdbc.driver.OraclePreparedStatement.setNull (OraclePreparedStatement.java:1424)
at org.apache.commons.dbcp.DelegatingPreparedStatemen t.setNull(DelegatingPreparedStatement.java:104)
at org.springframework.jdbc.core.StatementCreatorUtil s.setParameterValueInternal(StatementCreatorUtils. java:154)
at org.springframework.jdbc.core.StatementCreatorUtil s.setParameterValue(StatementCreatorUtils.java:94)
at org.springframework.jdbc.core.ArgPreparedStatement Setter.setValues(ArgPreparedStatementSetter.java:5 1)
at org.springframework.jdbc.core.JdbcTemplate$2.doInP reparedStatement(JdbcTemplate.java:742)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:537)
at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:738)
at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:796)
at org.springframework.jdbc.core.JdbcTemplate.update( JdbcTemplate.java:804)
at org.springframework.batch.execution.repository.dao .JdbcStepDao.update(JdbcStepDao.java:623)
at org.springframework.batch.execution.repository.Sim pleJobRepository.update(SimpleJobRepository.java:2 79)
... (AOP transaction stuff)
at $Proxy10.update(Unknown Source)
at org.springframework.batch.execution.step.simple.Si mpleStepExecutor.updateStatus(SimpleStepExecutor.j ava:304)
at org.springframework.batch.execution.step.simple.Si mpleStepExecutor.execute(SimpleStepExecutor.java:2 75)
at org.springframework.batch.execution.step.simple.Si mpleStep.execute(AbstractStep.java:131)
at org.springframework.batch.execution.job.simple.Sim pleJob.execute(SimpleJob.java:82)


Note: I had to change the datatype of LAST_STEP_EXECUTION_ID from BIGINT to NUMBER, as BIGINT datatype does not exist in Oracle9.

When exploring this issue, I noticed that in SimpleStepExecutor.updateStatus(), the stepInstance is updated before stepExecution is created and is assigned an ID, and therefore, LAST_STEP_EXECUTION_ID is set to null. Maybe the order should be reversed (first save or update step execution, then update step instance) ?

If this cannot be achieved for some reason and we can live with a null LAST_STEP_EXECUTION_ID, JdbcStepDao must use JdbcTemplate.update(String, Object[], int[]) instead of update(String, Object[]), in order to correctly set the datatypes of the parameters. I noticed that this simple change works. Maybe the above is a JdbcTemplate bug, or a JDBC driver bug ?

robert.kasanicky
Feb 18th, 2008, 08:09 AM
In m5-snapshot instance tables no longer have a reference to last execution, so updating to current trunk may solve your issue (update helped in http://jira.springframework.org/browse/BATCH-360)

adrianshum
Feb 18th, 2008, 10:40 PM
And I found that, in m4, schema-oracle10g.sql used datatypes that not exists in Oracle. You may fix occurence of BIGINT to, for example, NUMBER(38), and run the changed script yourself