2010/3/11 Peter Chen <peter.chen@stripped>:
> I am not sure whether do I need to modify something else? Like my application code.
as stated on the webpage you just posted here:
An application signals that it wants a transaction to be read-only by calling
Connection.setReadOnly(true), this replication-aware connection will
use one of the
slave connections, which are load-balanced per-vm using a round-robin scheme
So, I think you just need to set the readonly flag to "true" on the
via the setReadOnly() method. I can't tell you how to handle this
using the hibernate stuffs,
you should probably:
- post this question on an hibernate-related mailing list
- post this question on the Connector/J mailing list (there should be
one, I think! :)
- wait until someone else answers to this mail
- try it by yourself (my suggestion).
Finally, if you look at the user comments on the very same page, you will see an
entry explicitly dedicated to Hibernate, suggesting a way to configure
the persistence.xml file.
Regarding the automatic failover, I suggest you to investigate the
"autoReconnect" and "failOverReadOnly" flags of the Connector/J:
Greetings, and have a nice coding!