dijo wrote:
I am using hibernate2 with spring I want to implement transaction management. let me point out wat I was done so far..
I don't understand. Didn't you say you were now using hibernate3 instead of hibernate2 ?
About transaction management, you should consider using TransactionProxyFactoryBean class. This is the one that manages automatic tx demarcation. We use it without any problems, excerpt from our conf :
Code:
<bean id="serviceClientTarget" class="fr.mipih.formationj2ee.client.services.serviceclient.implementation.ServiceClient">
<property name="subService" ref="clientDao" />
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean id="serviceClient" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target" ref="serviceClientTarget" />
<property name="transactionAttributes">
<props>
<prop key="store">PROPAGATION_REQUIRED</prop>
<prop key="delete">PROPAGATION_REQUIRED</prop>
<prop key="load">PROPAGATION_REQUIRED</prop>
<prop key="find">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
You
have to define an interface for your service class. Then just get the proxy (here id="serviceClient"), never get directly the serviceClientTarget, that's to say. This is this proxy which will manage the tx demarcation.
I would also recommend you having a service layer in addition to your dao. Dao should not contain business logic, but just data access code (remember DAO means data access object).
Then in your service layer, you would not have to care about the type of data access is under (raw jdbc, file, or hibernate) but just keep on concentrate on business code.