Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring transactions with Objectify and Appengine

I am using appengine with Objectify to access my datasource. I use Spring for my business layer. In order to play with data I use the objectify-appengine-spring factory.

I would like to use annotation based local transactions. Do you know about an existing implementation which I could plug directly as a spring bean?

I'd really like to avoid the pain of implementing my own transaction provider with thread locals.

like image 735
Jordi P.S. Avatar asked Jan 20 '12 11:01

Jordi P.S.


1 Answers

Check LushLife's ObjectifyTransactionManager here or here.

Spring XML config needed (you can find it here or here):

<!-- ObjectifyManager -->
<bean id="objectifyManager" class="ex.objectify.spring.ObjectifyManager">
        <property name="basePackage" value="gso.model" />
</bean>

<!-- ObjectifyFactoryBean -->
<bean id="objectifyFactory" class="ex.objectify.spring.ObjectifyFactoryBean">
        <property name="manager" ref="objectifyManager" />
</bean>

<!-- Custom TransactionManager implementation -->
<bean id="transactionManager" class="ex.objectify.spring.ObjectifyTransactionManager">
        <property name="manager" ref="objectifyManager" />
</bean>

<!-- Necesary to enable use of @Transactional in your services -->
<tx:annotation-driven />

Don't forget to annotate your transactional methods or classes with @Transactional.

Special thanks to author of this project.

like image 63
jelies Avatar answered Oct 14 '22 00:10

jelies