Creating basic transaction using annotations with Spring for Hibernate.
To process annotation-based transaction configuration a transactionManager bean needs to be created and this will be used by <tx:annotation-driven/> for managing transactions.
<?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:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <import resource="classpath:org/springbyexample/orm/hibernate3/shared-context.xml"/> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" /> <tx:annotation-driven/> <bean id="personDao" class="org.springbyexample.orm.hibernate3.dao.PersonDaoImpl" p:sessionFactory-ref="sessionFactory" /> </beans>