Details
-
Type:
Improvement
-
Status: Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 3.0.5
-
Fix Version/s: Contributions Welcome
-
Component/s: Data, Transaction
-
Labels:
-
Last commented by a User:true
Description
We are using Spring and EclipseLink to establish two separated connection pools to replicated MySQL systems.
One connection pool contains "write" connections and should interact with the MySQL master only. The other connection pool contains "read" connections addressing the MySQL slaves.
These pools are established using EclipseLink's connection pool implementation and the MySQL replication driver.
This driver decides whether to address the MySQL master or slave host(s) based on the connection's "readOnly" attribute. Connections having "readOnly=true" will be executed on any of the configured slaves while "readOnly=false" will address the MySQL master system.
We use the Transactional annotation in order to control whether our methods should make use of read or write connections, e.g.:
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
Unfortunately the annotation's "readOnly" attribute is never transformed into read-only database connections in our environment.
It seems as if the EclipseLinkJpaDialect is missing to set this attribute in the getJdbcConnection method:
@Override
public ConnectionHandle getJdbcConnection(EntityManager em, boolean readOnly)
throws PersistenceException, SQLException
Calling the connections's setReadOnly method would fix the issue and enable the MySQL replication driver to address the correct DBMS:
...
Connection con = session.getAccessor().getConnection();
con.setReadOnly(readOnly);
return (con != null ? new SimpleConnectionHandle(con) : null);
}
Could this be a Spring bug or are we missing anything in our application configuration?
Is there any reason why the current getJdbcConnection implementation ignores the present "readOnly" argument?
Attachments
Issue Links
- is related to
-
SPR-7753 Spring's JDBC connection access disables shared cache in EclipseLink
-
- Closed
-