public class ReadOnlyRoutingDataSource
extends org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
AbstractRoutingDataSource implementation that routes to different
read only data source in a random fashion if the current transaction is read-only. This is useful for database
platforms that support read-replicas (like MySQL) to scale up the access to the database for read-only accesses.
Note: In order to use read-only replicas it is necessary to wrap this data source with a LazyConnectionDataSourceProxy to ensure that the connection is not fetched
during transaction creation, but during the first physical access. See the LazyConnectionDataSourceProxy
documentation for more details.
LazyConnectionDataSourceProxy| Constructor and Description |
|---|
ReadOnlyRoutingDataSource() |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
determineCurrentLookupKey() |
List<Object> |
getDataSources() |
void |
setDefaultTargetDataSource(Object defaultTargetDataSource) |
void |
setTargetDataSources(Map<Object,Object> targetDataSources) |
afterPropertiesSet, determineTargetDataSource, getConnection, getConnection, isWrapperFor, resolveSpecifiedDataSource, resolveSpecifiedLookupKey, setDataSourceLookup, setLenientFallback, unwrappublic void setTargetDataSources(Map<Object,Object> targetDataSources)
setTargetDataSources in class org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSourcepublic void setDefaultTargetDataSource(Object defaultTargetDataSource)
setDefaultTargetDataSource in class org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSourceprotected Object determineCurrentLookupKey()
determineCurrentLookupKey in class org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSourceCopyright © 2017 Pivotal Software, Inc.. All rights reserved.