6

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.

krishnakumarp
  • 8,967
  • 3
  • 49
  • 55
Jordi P.S.
  • 3,838
  • 7
  • 36
  • 59

2 Answers2

3

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.

jelies
  • 9,110
  • 5
  • 50
  • 65
  • Oh! Interesting ;) Can you post an example of the configuration (xml) and usage of the transaction manager? – Jordi P.S. Sep 20 '12 at 14:42
  • I was searching how to integrate spring & objectify and found this TransactionManager (it's not mine!). Browsing project's source code you can see that is used like any other one, using classical Spring `@Transactional` support approach. I'm going to update my answer with this information. – jelies Sep 20 '12 at 15:53
  • 1
    força barça? o força catalunya ? :P – Jordi P.S. Sep 21 '12 at 07:28
0

I guess the solution works only for Objectify3.

Any solution where I can use transaction attributes (MANDATORY, REQUIRED etc.) in Spring AOP + Objectify4 transactions - XML or Annotation?

Moreover, API docs for Objectify4 still mentions use of the ObjectifyFactory method beginTransaction() which I guess is not available anymore. It creates confusion for beginners. Would be more useful if the docs are updated to reflect the latest behavior. I hope I am not missing anything.

TechExplorer
  • 941
  • 7
  • 9