Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Frameworks
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other Application Frameworks
Transactions with Spring and Hibernate
Jim Baker
Ranch Hand
Posts: 177
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I'm using Hibernate3 with Spring2. Both Hibernate and Spring handles the
transaction, which should be used? Or both?
I'm currently using Hibernate transaction through a datasource. The Hibernate
DAO is injected in the service class through Spring.
Nick Williamson
Ranch Hand
Posts: 73
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is how I would do it: have a base bean that all your services can extend your transaction service so your transactions are at the service level. I'd be interested to see another way of doing this.
<bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> <property name="dataSource" ref="dataSource"/> </bean> <!-- transaction manager service used for base --> <bean id="txService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager" ref="hibernateTransactionManager"/> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!-- DAO/SERVICE DEF --> <bean id="TestDao" class="com.site.dao.impl.TestDaoImpl"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="TestService" parent="txService"> <property name="target" ref="TestServiceTarget"/> </bean> <bean id="TestServiceTarget" class="com.site.service.impl.TestServiceImpl"> <property name="testDao" ref="TestDao"/> </bean>
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Hibernate transaction with Spring
Hibernate transaction with Spring
JTA with Tomcat in JEE 6
Hibernate Transactions
Transaction error with Spring, Hibernate and JBOSS
More...