102
102
* @author Peter Zozom
103
103
* @author Robert Kasanicky
104
104
* @author Thomas Risberg
105
+ * @author Michael Minella
105
106
*/
106
107
public abstract class AbstractCursorItemReader <T > extends AbstractItemCountingItemStreamItemReader <T >
107
108
implements InitializingBean {
@@ -134,9 +135,9 @@ public abstract class AbstractCursorItemReader<T> extends AbstractItemCountingIt
134
135
135
136
private boolean useSharedExtendedConnection = false ;
136
137
137
- private Boolean connectionAutoCommit ;
138
+ private boolean connectionAutoCommit ;
138
139
139
- private Boolean initialConnectionAutoCommit ;
140
+ private boolean initialConnectionAutoCommit ;
140
141
141
142
public AbstractCursorItemReader () {
142
143
super ();
@@ -364,20 +365,12 @@ public boolean isUseSharedExtendedConnection() {
364
365
* Connection / Datasource default configuration.
365
366
*
366
367
* @param autoCommit value used for {@link Connection#setAutoCommit(boolean)}.
368
+ * @since 4.0
367
369
*/
368
370
public void setConnectionAutoCommit (boolean autoCommit ) {
369
371
this .connectionAutoCommit = autoCommit ;
370
372
}
371
373
372
- /**
373
- * Return whether "autoCommit" should be overridden for the connection used by the cursor.
374
- *
375
- * @return the "autoCommit" value, or {@code null} if none to be applied.
376
- */
377
- public Boolean getConnectionAutoCommit () {
378
- return this .connectionAutoCommit ;
379
- }
380
-
381
374
public abstract String getSql ();
382
375
383
376
/**
@@ -402,9 +395,9 @@ protected void doClose() throws Exception {
402
395
JdbcUtils .closeResultSet (this .rs );
403
396
rs = null ;
404
397
cleanupOnClose ();
405
- if ( this . initialConnectionAutoCommit != null ) {
406
- this .con .setAutoCommit (initialConnectionAutoCommit );
407
- }
398
+
399
+ this .con .setAutoCommit (initialConnectionAutoCommit );
400
+
408
401
if (useSharedExtendedConnection && dataSource instanceof ExtendedConnectionDataSourceProxy ) {
409
402
((ExtendedConnectionDataSourceProxy )dataSource ).stopCloseSuppression (this .con );
410
403
if (!TransactionSynchronizationManager .isActualTransactionActive ()) {
@@ -449,8 +442,10 @@ protected void initializeConnection() {
449
442
else {
450
443
this .con = dataSource .getConnection ();
451
444
}
452
- if (this .connectionAutoCommit != null && this .con .getAutoCommit () != this .connectionAutoCommit ) {
453
- this .initialConnectionAutoCommit = this .con .getAutoCommit ();
445
+
446
+ this .initialConnectionAutoCommit = this .con .getAutoCommit ();
447
+
448
+ if (this .con .getAutoCommit () != this .connectionAutoCommit ) {
454
449
this .con .setAutoCommit (this .connectionAutoCommit );
455
450
}
456
451
}
0 commit comments