I used Spring roo 1.00 to create a domain class, foo.domain.Profile, generated its integration test and the testMarkerMethod() everything works sweet.
After I pushed in all the persistence methods into the domain class, developed an DAO e.g. foo.api.FooImpl that make use of the domain class's foo.domain.Profile's persist() indirectly to save the object into the data store but it does not seem to commit. Further investigation showed that there is no transaction created. The applicationContext.xml is as the following -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schem...-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schem...ng-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schem...ing-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schem...ontext-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<!-- Hack for JBoss until full compliance is reached -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityMana gerFactoryBean">
<property name="persistenceUnitName" value="MySQL_Local" />
</bean>
<!--
Configure the Spring framework to use JTA transactions from Atomikos
-->
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTran sactionManager">
<property name="transactionManager" ref="atomikosTransactionManager" />
<property name="userTransaction" ref="atomikosUserTransaction" />
<property name="transactionSynchronizationName" value="SYNCHRONIZATION_ON_ACTUAL_TRANSACTION" />
</bean>
<!-- Define domain classes that uses the EMF -->
<bean id="profile" class="foo.domain.Profile">
<property name="emf" ref="entityManagerFactory" />
</bean>
<!-- This is a api object that we want to make transactional.
-->
<bean id="fooImpl" class="foo.api.FooImpl" />
<tx:annotation-driven/>
<context:component-scan annotation-config="true" base-package="foo.domain"/>
<context:component-scan annotation-config="true" base-package="foo.api"/>
<!--
************************************************** ******************
-->
<!-- PropertyConfigurer for the DAO -->
<!--
************************************************** ******************
-->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="location" value="classpath:database.properties" />
</bean>
<!--
************************************************** ******************
-->
<!-- Setup the transaction manager -->
<!--
************************************************** ******************
-->
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionMana ger"
init-method="init" destroy-method="close">
<property name="forceShutdown" value="true" />
<property name="startupTransactionService" value="true" />
<property name="transactionTimeout" value="60" />
</bean>
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" />
<!--
************************************************** ******************
-->
<!-- A distinct entry for each persistence unit used in this project -->
<!--
************************************************** ******************
-->
<!-- Make a Datasource -->
<bean id="MySQL_LocalDS" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSo urceBean">
<property name="uniqueResourceName" value="MySQL_Local__d3LUsKoLEd6rXPx8MV95xA" />
<property name="driverClassName" value="${MySQL_Local.connection.driver_class}" />
<property name="user" value="${MySQL_Local.connection.username}" />
<property name="password" value="${MySQL_Local.connection.password}" />
<property name="url" value="${MySQL_Local.connection.url}" />
<property name="minPoolSize" value="${MySQL_Local.minPoolSize}" />
<property name="maxPoolSize" value="${MySQL_Local.maxPoolSize}" />
<!-- http://forum.springsource.org/showthread.php?t=67728 -->
<property name="borrowConnectionTimeout" value="120" />
<property name="testQuery" value="SELECT 1" />
<property name="reapTimeout" value="0" />
</bean>
<!-- Configure a JPA vendor adapter -->
<bean id="MySQL_LocalJPAVendorAdapter"
class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
<property name="showSql" value="${MySQL_Local.show_sql}" />
<property name="generateDdl" value="${MySQL_Local.generateDdl}" />
<property name="databasePlatform" value="${MySQL_Local.dialect}" />
</bean>
<!--
now an EntityManager Factory that brings together the persistence
unit, datasource, and JPA Vendor
-->
<bean id="MySQL_Local"
class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
<property name="dataSource" ref="MySQL_LocalDS" />
<property name="persistenceUnitName" value="MySQL_Local" />
<property name="jpaVendorAdapter" ref="MySQL_LocalJPAVendorAdapter" />
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.transaction.manager_lookup_class"
value="com.atomikos.icatch.jta.hibernate3.Transact ionManagerLookup" />
<entry key="hibernate.connection.release_mode" value="on_close" />
</map>
</property>
</bean>
</beans>
(to continue as next reply ...)


Reply With Quote