-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ReplicationDriver with @Version
PostPosted: Mon Oct 15, 2012 12:31 pm 
Newbie

Joined: Tue Aug 21, 2007 5:01 pm
Posts: 3
I have an app that is read-mostly on MySQL 5.1.x with one master and multiple replication slaves. I would like to use the slaves for all read operations and the master for all write operations. Here are my options and why I don't like any of them:

JBoss Cache, Infinispan, etc:
I already have a cache. It's a MySQL slave. I don't want to create an additional cache.

Shards:
Maintenance nightmare

com.mysql.jdbc.ReplicationDriver:
Requires the developer to setReadOnly(true) for read-only transaction. All of the transactions are mostly reads with only a few writes, so I'd never be able to setReadOnly(true)

The ReplicationDriver solution is close, but it requires mixing in the setReadOnly() call to my business logic, which is undesirable, unreliable and just doesn't work for my case. However, if my entities are using the @Version annotation, I don't see why I can't select all my entities from a slave, and write them all to the master. The @Version annotation will cause Hibernate to throw an OptimisticLockException if my replication lags behind.

Basically, at the beginning of flush() I just want to switch to the master for writes. But how??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.