This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to handle transaction in DAO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to handle transaction in DAO" Watch "How to handle transaction in DAO" New topic
Author

How to handle transaction in DAO

amit sharma
Ranch Hand

Joined: Jul 19, 2006
Posts: 129
I make DAO for USER. I make a new connection in each method(CRUD) of DAO. I want to know what is the best strategy to handle transaction in DAO pattern. How can i call another DAO from DAO class.
Deepak Pant
Ranch Hand

Joined: Feb 13, 2004
Posts: 443
I think the answer to your question lies in following questions:
1. Are you using EJBs in your application ?
2. Or any other framework like Spring/Hibernate etc.

Generally I have not seen DAO calling another DAO. DAO to me are specialized extensions of the business components (EJB or POJO), which contain data access code. I think it should be Business component calling another business component.

The transaction handling will come from the first two questions.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to handle transaction in DAO
 
Similar Threads
handle the Transaction on the DB side ?
Hibernate and EJB
Should it be one DAO per entity?
Handling Hibernate Session for Container Managed transactions
Hibernate Transactions