I want Hibernate to make use of the Replication (Master/Slave).
Below is our datasource:
<datasources>
<local-tx-datasource>
<jndi-name>PortalDS</jndi-name>
<connection-url>jdbc:mysql://masterurl:3399,slaveurl:4498/mydb</connection-url>
<driver-class>com.mysql.jdbc.ReplicationDriver</driver-class>
<user-name>system</user-name>
<password>system</password>
<autoReconnect>true</autoReconnect>
<roundRobinLoadBalance>true</roundRobinLoadBalance>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements/>
</local-tx-datasource>
</datasources>
I am extending on the MySQLInnoDBDialect
Below is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd" version="1.0">
<persistence-unit name="PortalDS">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/PortalDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="com.at.hib.helpers.ATDialect" />
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.transaction.flush_before_completion" value="true" />
<property name="hibernate.transaction.auto_close_session" value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property name="hibernate.session_factory_name" value="ATHibernateFactory" />
<property name="hibernate.cache.region_prefix" value=""/>
</properties>
</persistence-unit>
</persistence>
I am seeing the connection created on both the master and the slave. I made a modification on the slave for a table, but when Hibernate queries - it seems to be looking at the master.
What am I missing?