diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java index 79cf51e71d0..1b4f69c8ccf 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,13 +121,28 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource { this.defaultAutoCommit = defaultAutoCommit; } + /** + * Set the default transaction isolation level by the name of the corresponding + * constant in {@link java.sql.Connection} — for example, + * {@code "TRANSACTION_SERIALIZABLE"}. + * @param constantName name of the constant + * @see #setDefaultTransactionIsolation + * @see java.sql.Connection#TRANSACTION_READ_UNCOMMITTED + * @see java.sql.Connection#TRANSACTION_READ_COMMITTED + * @see java.sql.Connection#TRANSACTION_REPEATABLE_READ + * @see java.sql.Connection#TRANSACTION_SERIALIZABLE + */ + public void setDefaultTransactionIsolationName(String constantName) { + setDefaultTransactionIsolation(constants.asNumber(constantName).intValue()); + } + /** * Set the default transaction isolation level to expose when no target Connection * has been fetched yet (when the actual JDBC Connection default is not known yet). *
This property accepts the int constant value (e.g. 8) as defined in the * {@link java.sql.Connection} interface; it is mainly intended for programmatic * use. Consider using the "defaultTransactionIsolationName" property for setting - * the value by name (e.g. "TRANSACTION_SERIALIZABLE"). + * the value by name (for example, {@code "TRANSACTION_SERIALIZABLE"}). *
If not specified, the default gets determined by checking a target * Connection on startup. If that check fails, the default will be determined * lazily on first access of a Connection. @@ -138,20 +153,6 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource { this.defaultTransactionIsolation = defaultTransactionIsolation; } - /** - * Set the default transaction isolation level by the name of the corresponding - * constant in {@link java.sql.Connection}, e.g. "TRANSACTION_SERIALIZABLE". - * @param constantName name of the constant - * @see #setDefaultTransactionIsolation - * @see java.sql.Connection#TRANSACTION_READ_UNCOMMITTED - * @see java.sql.Connection#TRANSACTION_READ_COMMITTED - * @see java.sql.Connection#TRANSACTION_REPEATABLE_READ - * @see java.sql.Connection#TRANSACTION_SERIALIZABLE - */ - public void setDefaultTransactionIsolationName(String constantName) { - setDefaultTransactionIsolation(constants.asNumber(constantName).intValue()); - } - @Override public void afterPropertiesSet() {