1) Transaction Manager yaratma
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<!-- <property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/> -->
<property name="url" value="jdbc:hsqldb:mem:BankApp"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
Bunu DataSourceTransactionManager kullaniyoruz cunku, JDBC kullaniyoruz. Eger Hibernate kullansaydik,
transactionManager'imizin adi HibernateTransactionManager olmaliydi.
Bu asagidakiler yerine,
To do setAutoCommit(false);
To use Same Connection from datasource
Commit If all successful
Rollback is not successful
@Transactional annotation ekleriz ve hepsi olur. Bunu metoda ekleriz. Eger class'a eklersek, butun public metodlar
transactional olur
2) <tx:annotation-driven/> 'in eklenmesi gerekiyor. Bu BeanPostProcessor'a @Transacitonal'lari
handleetme davranisini register ediyor.
Search Blog
Sunday, January 22, 2012
Spring Transaction Management 1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment