List:General Discussion« Previous MessageNext Message »
From:Mattia Merzi Date:March 11 2010 12:34pm
Subject:Re: How to modify the application to implement the separation of
write/read
View as plain text  
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
connection objects
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:
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html

Greetings, and have a nice coding!

Mattia.
Thread
How to modify the application to implement the separation of write/readPeter Chen11 Mar
  • Re: How to modify the application to implement the separation of write/readMattia Merzi11 Mar
    • RE: How to modify the application to implement the separation of write/readPeter Chen11 Mar
      • Re: How to modify the application to implement the separation of write/readMattia Merzi11 Mar
      • RE: How to modify the application to implement the separation of write/readDaevid Vincent11 Mar