I was going over the DAO pattern example..Its about Movies.. so basically i have MovieDAO ,MovieDAOFactory ,MoviDAOImpl .. this 3 classes..so 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 "
-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 ...)