Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

DAO - best practices

Thread view: 
R - 18 Apr 2006 09:26 GMT
Hi All,

I know this is a little bit OT

Suppose I have 2 tables customers and products, customer can buy many
products, product can be bought by many customers - typical n:m
relationship so 3rd table is a must: i.e. purchases

So I need 3 DAO: ProductDAO, CustomerDAO and PurchaseDAO.

How do you deal with i.e. reports - table joins, left joins or
statistics (group by, max, min etc)?

do you create DAOs for that? (especially table joins - probably not)

raports and statistics from i.e. 7 tables can be only read-only, so
insert, update, delete methods
are inadequate.

thanks in advance for shedding some light on this
best regards
R
PremKumar - 18 Apr 2006 10:18 GMT
Hi,
Yep, 3 tables needed;  for customer details, product details and
purchase details.
No need for U to have 3 DAO's

In one DAO  you can get all the detials U need like;
pick list for products
pick list for customers
for repo's etc.,

Cheers
richardsosborn@gmail.com - 27 Apr 2006 14:40 GMT
you need to change your thinking.  DAO is an intersection between DB
and the java code you're writing.  you should think if it as the person
coming into it after you for the first time will see it.

your method names, as the last poster said, should start to crossover
from describing the business action  performs, to which database
interaction needs to take place. ("pickProductList()" as opposed to
"pickListFromProductItemsTable()")  this is the point of DAO.

if you want another layer of abstraction, i've seen projects which
start to describe which queries or database actions will be performed
(IE "callPickListForProductItems()").  and even then contain these in a
specialized class for each database vendor, in case your application
would re-platform.

but the pattern serves you, not the other way around.  be aware of the
future and utilize as much or as little as you think you will need.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.