|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2010 the original author or authors. |
| 2 | + * Copyright 2002-2013 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
66 | 66 | * You will get the same effect with non-transactional reads, but lazy fetching
|
67 | 67 | * of JDBC Connections allows you to still perform reads in transactions.
|
68 | 68 | *
|
69 |
| - * <p><b>NOTE:</b> This DataSource proxy needs to return wrapped Connections to |
70 |
| - * handle lazy fetching of an actual JDBC Connection. Therefore, the returned |
71 |
| - * Connections cannot be cast to a native JDBC Connection type like OracleConnection, |
72 |
| - * or to a connection pool implementation type. Use a corresponding |
73 |
| - * NativeJdbcExtractor to retrieve the native JDBC Connection. |
| 69 | + * <p><b>NOTE:</b> This DataSource proxy needs to return wrapped Connections |
| 70 | + * (which implement the {@link ConnectionProxy} interface) in order to handle |
| 71 | + * lazy fetching of an actual JDBC Connection. Therefore, the returned Connections |
| 72 | + * cannot be cast to a native JDBC Connection type such as OracleConnection or |
| 73 | + * to a connection pool implementation type. Use a corresponding |
| 74 | + * {@link org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor} |
| 75 | + * or JDBC 4's {@link Connection#unwrap} to retrieve the native JDBC Connection. |
74 | 76 | *
|
75 | 77 | * @author Juergen Hoeller
|
76 | 78 | * @since 1.1.4
|
77 |
| - * @see ConnectionProxy |
78 | 79 | * @see DataSourceTransactionManager
|
79 |
| - * @see org.springframework.orm.hibernate3.HibernateTransactionManager |
80 |
| - * @see org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor |
81 | 80 | */
|
82 | 81 | public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
|
83 | 82 |
|
@@ -407,7 +406,13 @@ private Connection getTargetConnection(Method operation) throws SQLException {
|
407 | 406 |
|
408 | 407 | // Apply kept transaction settings, if any.
|
409 | 408 | if (this.readOnly) {
|
410 |
| - this.target.setReadOnly(this.readOnly); |
| 409 | + try { |
| 410 | + this.target.setReadOnly(this.readOnly); |
| 411 | + } |
| 412 | + catch (Exception ex) { |
| 413 | + // "read-only not supported" -> ignore, it's just a hint anyway |
| 414 | + logger.debug("Could not set JDBC Connection read-only", ex); |
| 415 | + } |
411 | 416 | }
|
412 | 417 | if (this.transactionIsolation != null &&
|
413 | 418 | !this.transactionIsolation.equals(defaultTransactionIsolation())) {
|
|
0 commit comments