File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Implement Transactions best way, in my application    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Implement Transactions best way, in my application    " Watch "Implement Transactions best way, in my application    " New topic
Author

Implement Transactions best way, in my application

Sajith Hasanka
Greenhorn

Joined: Aug 20, 2009
Posts: 17
Hi all,

I 'm currently developing an application, 3 - tire one, where its business services are exposed as web services, and those web services directly invokes DAO operations for data base operations.

I have a question, what is the best way to implement transsactions in my application.

Do i need to implement transactions in both Service layer as well as DAO layer ? if not is it enough to implemnt in only one layer?
What are the disadvantages im facing if i implement TX in both layers?

What are the techniques i have to follow, i mean, are there specific techniques to implement service level transactions compared to DAO transactions?
can i use spring frameowrk? with AOP support?

I'm really confused abt the way i should handle transactions, so your reply will be a huge help for me... thanks in advance

Thanks a lot
saj
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30506
    
150

Saj,
You mean tier and not tire. This might have been a typo, but I wanted to call your attention to it in case it is not.

Do i need to implement transactions in both Service layer as well as DAO layer ?

No. I usually only use transactions in the service layer.

if not is it enough to implemnt in only one layer?

Yes. The advantage of the service layer is it makes the whole service one logical transaction. Which tends to be what you need.

What are the disadvantages im facing if i implement TX in both layers?

It depends on the settings and your requirement. Do you have a requirement that the DAO roll back independently? If not, the setting would be to use the service layer's transaction. And the disadvantage would be added complexity.

What are the techniques i have to follow, i mean, are there specific techniques to implement service level transactions compared to DAO transactions? can i use spring frameowrk?

Yes, Spring is a good way to create a service level transaction.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sajith Hasanka
Greenhorn

Joined: Aug 20, 2009
Posts: 17
Hi Jeanne ,

Thanks a lot for your reply, and it solves my doubts and you have replied the way i was expecting, and ya, i meant tier , not tire .. typo
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

"s hk", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sajith Hasanka
Greenhorn

Joined: Aug 20, 2009
Posts: 17
done
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implement Transactions best way, in my application