This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
How to apply different PROPAGATION transaction attributes for methods in SERVICE and DAO layers using Classic Spring AOP(i.e using TransactionProxyFactoryBean)?
Below Example is using @Transactional annotation. I would like know How to apply the same using TransactionProxyFactoryBean(Spring 1.x) (or) Transaction Advices(Spring 2.xi.e <tx:advice> and <aop:config>)
// example beans.xml with TransactionProxyFactoryBean .
Here I could able to configure "transactionAttributes" for only Service(i.e Cashier) methods . How to apply "transactionAttributes" differently for DAO(i.e BookShop) methods like we did using @Transactional Annotation ? and the same with <tx:advice> ,<aop:config> ?
// example beans.xml using Trasaction Advices(Spring 2.x way)
look at the attributes of tx:method. It includes all the attributes of the @Transactional annotation.
sorry Mark, I have placed "cashier" instead of "chechout" in <tx:method>
moreover in <tx:method> "checkout" is the name of the method in Cashier interface(i.e Service layer) & for that "checkout" method we are applying default transaction attributes. Now I would like to apply like <tx:method name="purchase" propagation="REQUIRES_NEW"/> <-- "purchase" is BookShop (DAO layer) interface method.
can I configure like the below? please help me in this.
even I tried the above one, but it is not working correctly.
Initial data in the tables
SQL> select * from BOOK;
ISBN BOOK_NAME PRICE
---------- ------------------------- ----------
0001 The First Book 30
0002 The Second Book 50
because, there should be one successful Transaction of First time purchase("0001","user1") method execution. But when run the above code with that configuration (<tx:advice>) in beans.xml I am not getting the first purchase()'s transaction successfully to get the data in DataBase as show above.