[Neo] MySQL and Neo within same transaction configured in Spring

Andreas Guenther aguenther at flying-orange.com
Thu Apr 30 07:22:06 CEST 2009


Hi,

I am in the process of considering to use Neo for my company. So far I 
am impressed with the results and capabilities. That said, after a week 
of getting to know Neo on the feature side I came across an integration 
obstacle regarding transactions. Basically, I have been trying to use 
MySQL and Neo together in the same transaction context using JTA/XA and 
Spring.

#1 Is it at all possible to use a single transaction manager for MySQL 
and Neo, ideally out of the box?

#2 Does anyone have an example on how this could be configured in Spring?

Below is a snippet I somewhat started but got stuck on:

    <bean id="jotm" 
class="org.springframework.transaction.jta.JotmFactoryBean"/>

    <bean id="transactionManager" 
class="org.springframework.transaction.jta.JtaTransactionManager">
       <property name="userTransaction" value="jotm"/>
    </bean>

    <bean id="mysqlXADataSource" 
class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" 
destroy-method="shutdown">
       <property name="dataSource">
          <bean class="org.enhydra.jdbc.standard.StandardXADataSource" 
destroy-method="shutdown">
             <property name="transactionManager" ref="jotm" />
             <property name="driverName" value="${jdbc.driver}" />
             <property name="url" 
value="${jdbc.url}/test?zeroDateTimeBehavior=convertToNull" />
          </bean>
       </property>
       <property name="user" value="${jdbc.username}"/>
       <property name="password" value="${jdbc.password}"/>
    </bean>

    <!-- This doesn't seem right to me, especially since I can't find a 
place to tell Neo about jotm -->
    <bean id="neoXADataSource" 
class="org.neo4j.impl.nioneo.xa.NeoStoreXaDataSource">
        <constructor-arg>
            <map>
                <entry key="store_dir" value="target/neo-db"/>
            </map>
        </constructor-arg>
    </bean>

    <!-- The following is what I used to start out with based on IMDb 
example
    <bean id="neoTransactionManagerService" 
class="org.neo4j.impl.transaction.SpringTransactionManager"/>
    <bean id="neoUserTransactionService" 
class="org.neo4j.impl.transaction.UserTransactionImpl"/>

    <bean id="transactionManager" 
class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManager" 
ref="neoTransactionManagerService"/>
        <property name="userTransaction" ref="neoUserTransactionService"/>
    </bean>
    -->

Thanks in advance,
-Andreas




More information about the User mailing list