I have a master/slave MySQL replication setup. I want all writes to be sent to the master, and all reads to the slave.
I change the jdbc driver to com.mysql.jdbc.ReplicationDriver with the url set to jdbc:mysql://master,slave/db,
The mysql docs for ReplicationDriver say that as soon as setReadOnly(false) is called, all further queries are passed to the master, if setReadOnly(true) is called, all further queries are passed to the slave.
I did some test, first, I try to get connection directly from DBCP Connection Pool, no Hibernate, both reading and writing work well.
after that, I tried to use Hibernate3.3, all updates work fine (passed to the master), but all reading sent to the master too (It should be passed to Slave), that's weird.
I tried session.connection().setReadOnly(true) and query.setReadOnly(true), both don't work.
Does Hibernate support ReplicationDriver?
|