2424import  java .sql .PreparedStatement ;
2525import  java .sql .ResultSet ;
2626import  java .sql .SQLException ;
27+ import  java .sql .Types ;
2728import  java .util .Collection ;
2829import  java .util .HashMap ;
2930import  java .util .Iterator ;
30- import  java .util .List ;
3131import  java .util .Map ;
3232import  java .util .Map .Entry ;
3333import  java .util .concurrent .locks .Lock ;
@@ -64,7 +64,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
6464	private  static  final  String  FIND_JOB_EXECUTION_CONTEXT  = """ 
6565			SELECT SHORT_CONTEXT, SERIALIZED_CONTEXT 
6666			FROM %PREFIX%JOB_EXECUTION_CONTEXT 
67- 			WHERE JOB_EXECUTION_ID = ?  
67+ 			WHERE JOB_EXECUTION_ID = :jobExecutionId  
6868			""" ;
6969
7070	private  static  final  String  INSERT_JOB_EXECUTION_CONTEXT  = """ 
@@ -81,7 +81,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
8181	private  static  final  String  FIND_STEP_EXECUTION_CONTEXT  = """ 
8282			SELECT SHORT_CONTEXT, SERIALIZED_CONTEXT 
8383			FROM %PREFIX%STEP_EXECUTION_CONTEXT 
84- 			WHERE STEP_EXECUTION_ID = ?  
84+ 			WHERE STEP_EXECUTION_ID = :stepExecutionId  
8585			""" ;
8686
8787	private  static  final  String  INSERT_STEP_EXECUTION_CONTEXT  = """ 
@@ -97,12 +97,12 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
9797
9898	private  static  final  String  DELETE_STEP_EXECUTION_CONTEXT  = """ 
9999			DELETE FROM %PREFIX%STEP_EXECUTION_CONTEXT 
100- 			WHERE STEP_EXECUTION_ID = ?  
100+ 			WHERE STEP_EXECUTION_ID = :stepExecutionId  
101101			""" ;
102102
103103	private  static  final  String  DELETE_JOB_EXECUTION_CONTEXT  = """ 
104104			DELETE FROM %PREFIX%JOB_EXECUTION_CONTEXT 
105- 			WHERE JOB_EXECUTION_ID = ?  
105+ 			WHERE JOB_EXECUTION_ID = :jobExecutionId  
106106			""" ;
107107
108108	private  Charset  charset  = StandardCharsets .UTF_8 ;
@@ -153,29 +153,24 @@ public ExecutionContext getExecutionContext(JobExecution jobExecution) {
153153		Long  executionId  = jobExecution .getId ();
154154		Assert .notNull (executionId , "ExecutionId must not be null." );
155155
156- 		List <ExecutionContext > results  = getJdbcTemplate ().query (getQuery (FIND_JOB_EXECUTION_CONTEXT ),
157- 				new  ExecutionContextRowMapper (), executionId );
158- 		if  (!results .isEmpty ()) {
159- 			return  results .get (0 );
160- 		}
161- 		else  {
162- 			return  new  ExecutionContext ();
163- 		}
156+ 		return  getJdbcClient ().sql (getQuery (FIND_JOB_EXECUTION_CONTEXT ))
157+ 			.param ("jobExecutionId" , executionId )
158+ 			.query (new  ExecutionContextRowMapper ())
159+ 			.optional ()
160+ 			.orElseGet (ExecutionContext ::new );
161+ 
164162	}
165163
166164	@ Override 
167165	public  ExecutionContext  getExecutionContext (StepExecution  stepExecution ) {
168166		Long  executionId  = stepExecution .getId ();
169167		Assert .notNull (executionId , "ExecutionId must not be null." );
170168
171- 		List <ExecutionContext > results  = getJdbcTemplate ().query (getQuery (FIND_STEP_EXECUTION_CONTEXT ),
172- 				new  ExecutionContextRowMapper (), executionId );
173- 		if  (results .size () > 0 ) {
174- 			return  results .get (0 );
175- 		}
176- 		else  {
177- 			return  new  ExecutionContext ();
178- 		}
169+ 		return  getJdbcClient ().sql (getQuery (FIND_STEP_EXECUTION_CONTEXT ))
170+ 			.param ("stepExecutionId" , executionId )
171+ 			.query (new  ExecutionContextRowMapper ())
172+ 			.optional ()
173+ 			.orElseGet (ExecutionContext ::new );
179174	}
180175
181176	@ Override 
@@ -255,7 +250,9 @@ public void saveExecutionContexts(Collection<StepExecution> stepExecutions) {
255250	 */ 
256251	@ Override 
257252	public  void  deleteExecutionContext (JobExecution  jobExecution ) {
258- 		getJdbcTemplate ().update (getQuery (DELETE_JOB_EXECUTION_CONTEXT ), jobExecution .getId ());
253+ 		getJdbcClient ().sql (getQuery (DELETE_JOB_EXECUTION_CONTEXT ))
254+ 			.param ("jobExecutionId" , jobExecution .getId ())
255+ 			.update ();
259256	}
260257
261258	/** 
@@ -264,7 +261,9 @@ public void deleteExecutionContext(JobExecution jobExecution) {
264261	 */ 
265262	@ Override 
266263	public  void  deleteExecutionContext (StepExecution  stepExecution ) {
267- 		getJdbcTemplate ().update (getQuery (DELETE_STEP_EXECUTION_CONTEXT ), stepExecution .getId ());
264+ 		getJdbcClient ().sql (getQuery (DELETE_STEP_EXECUTION_CONTEXT ))
265+ 			.param ("stepExecutionId" , stepExecution .getId ())
266+ 			.update ();
268267	}
269268
270269	@ Override 
@@ -293,16 +292,13 @@ private void persistSerializedContext(Long executionId, String serializedContext
293292			longContext  = null ;
294293		}
295294
296- 		getJdbcTemplate ().update (getQuery (sql ), ps  -> {
297- 			ps .setString (1 , shortContext );
298- 			if  (longContext  != null ) {
299- 				ps .setString (2 , longContext );
300- 			}
301- 			else  {
302- 				ps .setNull (2 , getClobTypeToUse ());
303- 			}
304- 			ps .setLong (3 , executionId );
305- 		});
295+ 		getJdbcClient ().sql (getQuery (sql ))
296+ 		// @formatter:off 
297+ 				.param (1 , shortContext , Types .VARCHAR )
298+ 				.param (2 , longContext , getClobTypeToUse ())
299+ 				.param (3 , executionId , Types .BIGINT )
300+ 		// @formatter:on 
301+ 			.update ();
306302	}
307303
308304	/** 
0 commit comments