@Override protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcOperations); dao.setTablePrefix(tablePrefix); dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType)); dao.setSerializer(serializer); if (lobHandler != null) { dao.setLobHandler(lobHandler); } dao.afterPropertiesSet(); // Assume the same length. dao.setShortContextLength(maxVarCharLength); return dao; }
@Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, shortContext); if (longContext != null) { lobHandler.getLobCreator().setClobAsString(ps, 2, longContext); } else { ps.setNull(2, getClobTypeToUse()); } ps.setLong(3, executionId); } });
getJdbcTemplate().update(getQuery(sql), new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException {
@Override protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcOperations); dao.setLobHandler(lobHandler); dao.setTablePrefix(tablePrefix); dao.setSerializer(serializer); dao.afterPropertiesSet(); return dao; }
@Test public void testNullSerializer() { try { JdbcExecutionContextDao jdbcExecutionContextDao = new JdbcExecutionContextDao(); jdbcExecutionContextDao.setJdbcTemplate(mock(JdbcOperations.class)); jdbcExecutionContextDao.setSerializer(null); jdbcExecutionContextDao.afterPropertiesSet(); } catch (Exception e) { Assert.assertTrue(e instanceof IllegalArgumentException); Assert.assertEquals("Serializer must not be null", e.getMessage()); } }
@Test public void testNoSerializer() { try { JdbcExecutionContextDao jdbcExecutionContextDao = new JdbcExecutionContextDao(); jdbcExecutionContextDao.setJdbcTemplate(mock(JdbcOperations.class)); jdbcExecutionContextDao.afterPropertiesSet(); } catch (Exception e) { Assert.assertTrue(e instanceof IllegalStateException); Assert.assertEquals("ExecutionContextSerializer is required", e.getMessage()); } }
@Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); this.serializer = getProperty("serializer"); } }
@Override protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcOperations); dao.setLobHandler(lobHandler); dao.setTablePrefix(tablePrefix); dao.setSerializer(serializer); dao.afterPropertiesSet(); return dao; }
protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcTemplate); dao.setTablePrefix(tablePrefix); dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType)); if (lobHandler != null) { dao.setLobHandler(lobHandler); } dao.setSerializer(serializer); dao.afterPropertiesSet(); // Assume the same length. dao.setShortContextLength(maxVarCharLength); return dao; }
@Override protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcOperations); dao.setLobHandler(lobHandler); dao.setTablePrefix(tablePrefix); dao.setSerializer(serializer); dao.afterPropertiesSet(); return dao; }
final Iterator<Long> executionIdIterator = serializedContexts.keySet().iterator(); getJdbcTemplate().batchUpdate(getQuery(sql), new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException {
@Override public void setValues(PreparedStatement ps, int i) throws SQLException { Long executionId = executionIdIterator.next(); String serializedContext = serializedContexts.get(executionId); String shortContext; String longContext; if (serializedContext.length() > shortContextLength) { // Overestimate length of ellipsis to be on the safe side with // 2-byte chars shortContext = serializedContext.substring(0, shortContextLength - 8) + " ..."; longContext = serializedContext; } else { shortContext = serializedContext; longContext = null; } ps.setString(1, shortContext); if (longContext != null) { lobHandler.getLobCreator().setClobAsString(ps, 2, longContext); } else { ps.setNull(2, getClobTypeToUse()); } ps.setLong(3, executionId); }
protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcTemplate); dao.setTablePrefix(tablePrefix); dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType)); if (lobHandler != null) { dao.setLobHandler(lobHandler); } dao.setSerializer(serializer); dao.afterPropertiesSet(); // Assume the same length. dao.setShortContextLength(maxVarCharLength); return dao; }
@Override protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcTemplate); dao.setLobHandler(lobHandler); dao.setTablePrefix(tablePrefix); dao.afterPropertiesSet(); return dao; }
@Override public ExecutionContext getExecutionContext(StepExecution stepExecution) { Long executionId = stepExecution.getId(); Assert.notNull(executionId, "ExecutionId must not be null."); List<ExecutionContext> results = getJdbcTemplate().query(getQuery(FIND_STEP_EXECUTION_CONTEXT), new ExecutionContextRowMapper(), executionId); if (results.size() > 0) { return results.get(0); } else { return new ExecutionContext(); } }
@Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, shortContext); if (longContext != null) { lobHandler.getLobCreator().setClobAsString(ps, 2, longContext); } else { ps.setNull(2, getClobTypeToUse()); } ps.setLong(3, executionId); } });
@Override protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcTemplate); dao.setTablePrefix(tablePrefix); dao.setClobTypeToUse(determineClobTypeToUse(this.databaseType)); if (lobHandler != null) { dao.setLobHandler(lobHandler); } dao.afterPropertiesSet(); // Assume the same length. dao.setShortContextLength(maxVarCharLength); return dao; }
@Override protected ExecutionContextDao createExecutionContextDao() throws Exception { JdbcExecutionContextDao dao = new JdbcExecutionContextDao(); dao.setJdbcTemplate(jdbcOperations); dao.setLobHandler(lobHandler); dao.setTablePrefix(tablePrefix); dao.setSerializer(serializer); dao.afterPropertiesSet(); return dao; }
@Override public ExecutionContext getExecutionContext(JobExecution jobExecution) { Long executionId = jobExecution.getId(); Assert.notNull(executionId, "ExecutionId must not be null."); List<ExecutionContext> results = getJdbcTemplate().query(getQuery(FIND_JOB_EXECUTION_CONTEXT), new ExecutionContextRowMapper(), executionId); if (results.size() > 0) { return results.get(0); } else { return new ExecutionContext(); } }
@Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, shortContext); if (longContext != null) { lobHandler.getLobCreator().setClobAsString(ps, 2, longContext); } else { ps.setNull(2, getClobTypeToUse()); } ps.setLong(3, executionId); } });