I'm using the MySql Connect/J ReplicationDriver to connect to my MySql master 
and slave databases.
I modified my -ds.xml file to use the ReplicationDriver and have both the 
master and slave in the connection-url.

It starts up fine but when I try to make a query go to the slave it throws an 
error:
You cannot set read only during a managed transaction!

The code snippet is inside a stateless bean:
....
                        HibernateSession hs = (HibernateSession) em;
                        Session session = hs.getHibernateSession();
                        session.connection().setReadOnly(true);
                        Query q = em.createQuery(query);
....

I'm not sure this is the correct way to set the connection to read only when 
using EntityManager but I can't see any other way via annotations or other 
settings.

Is there any way to get the query to be sent to the slave?  Use two 
entitymanagers with different ds?

Cheers,
Himmy

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114148#4114148

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114148
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to