Hi,
I have encountered problems using declarative transaction demarcation. I have a parent-child class "binded" using foreign key in Hibernate. In my business manager class, I have a save() method to save both the parent and child object. However, I realised that the Hibernate session closes (with a transaction completion message) after the parent class is being saved. To confirm that the transaction did not propagate to the child, i through an exception at the child's DAO class.
I am quite sure that there are some attribute that I did not set for my dataSource bean or transaction manager. Below is a small segment of my application context. Appreciate any help offered. Tks.
Code:<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>MY_DS</value></property> </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref local="myDataSource"/></property> <property name="mappingResources"> <list> <value>User.hbm</value> <value>OneOffFA.hbm</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="myTransactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"><ref local="mySessionFactory"/></property> </bean> <bean id="oneOffFADelegateTarget" class="delegate.financial.OneOffFADelegate"> <property name="workflowSvc"><ref bean="workflowSvc"/></property> <property name="paramMgr"><ref bean="paramMgr"/></property> <property name="txnCounter"><ref bean="transRefCounter"/></property> <property name="dao"><ref local="oneOffFADao"/></property> </bean> <bean id="oneOffFADelegate" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref bean="myTransactionManager"/></property> <property name="target"> <ref local="oneOffFADelegateTarget"/> </property> <property name="transactionAttributes"> <props> <prop key="save">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="oneOffFADao" class="iwads.dao.hibernate.OneOffFADaoImpl"> <property name="sessionFactory"><ref bean="mySessionFactory"/></property> </bean>


Reply With Quote