File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes how many DAO's should be there in applciation. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "how many DAO Watch "how many DAO New topic

how many DAO's should be there in applciation.

Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
I was going over the DAO pattern example..Its about Movies.. so basically i have MovieDAO ,MovieDAOFactory ,MoviDAOImpl .. this 3 i f i have user registration in my app then there should be Registration DAO also .. right .. How may DAO's should be there in application .. is it like similar to the number of controllers in the applciation .. for ex. CartController,LoginController...and finally where should the database conncetion related logic should be ideally ..Inside the DAO implementation class or anywhere else..what should be the ideal scenario for Movie Rental application ..??how the sturcture should be ..

SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "
Masoud Kalali
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

-we usually create one DAO per our database table or view that we need , usually DAO are used to encapsulate data access in a seperate layer.

-there are some conditions that we have one DAO for more than one table , for example when you need to update multiple tables per operation.

-DAO is just for data access and Logic should not be pushed into DAO layer
business rules should be handled in business service entities .

-connections come from a resource manager , where ever in our DAOimpl that we need a connection we get the connection from resource manager and resource manager should know where to get connection from (a connection pool / using a singletone pattern and plain jdbc and driver manager ...)

take a look at
for more information

Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
I agree. Here's the link:
subject: how many DAO's should be there in applciation.
It's not a secret anymore!