Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > DAO - best practices

Reply
Thread Tools

DAO - best practices

 
 
R
Guest
Posts: n/a
 
      04-18-2006
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

 
Reply With Quote
 
 
 
 
PremKumar
Guest
Posts: n/a
 
      04-18-2006
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

 
Reply With Quote
 
 
 
 
richardsosborn@gmail.com
Guest
Posts: n/a
 
      04-27-2006
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simpler over view on dao: a functional logic solver with builtinparsing power, and dinpy, the sugar syntax for dao in python Simeon Chaos Python 0 11-08-2011 05:34 AM
One table One Dao is the best practise????? lightning Java 1 07-08-2008 04:06 AM
Best Codeplex sample for showing best coding practices? John Dalberg ASP .Net 3 11-16-2006 12:07 PM
asp.net and dao? mirek ASP .Net 2 08-06-2003 10:54 AM
Best sample app for learning best practices, OO & asp.net? karim ASP .Net 0 07-13-2003 04:26 AM



Advertisments