Hi all,
I'm doing a project using Hibernate3.0. I have studied some tutorials on transactional management. However, when I implement it on my project, it's not work. The configuration is shown below:
[code]
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/test</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>123123</value>
</property>
</bean>
<bean class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" id="sessionFactory">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="lobHandler">
<ref local ="lobHandler"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean class="com.aat.dao.HibernateDAOImpl" id="HibernateDAO">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="tranFormTarget" class="com.aat.services.AssetTransferManagerImpl">
<property name="hibernateDAO" ref="HibernateDAO"/>
</bean>
<bean id="tranFormBean" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
<property name="target">
<ref local="tranFormTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="save">PROPAGATION_REQUIRED</prop>
<prop key="update">PROPAGATION_REQUIRED</prop>
<prop key="approve">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
public interface AssetTransferManager {
public void save(AssetTransferForm objForm) throws DataAccessException, SQLException, ParseException;
public void updateTranForm(TranForm obj);
public void approve(ActionForm form, HttpServletRequest request);
}
[/code]
When it runs with exception, the records cannot be rollback. What's wrong with it?
Thanks!!
Best regards,
Terry
|