modelling--DAO vs ORM

This is a discussion on modelling--DAO vs ORM within the JDBC JAVA forums in Framework and Interface Programming category; Hi, quick question about accessing the persistence layer, in particular using DAO vs. using ORM. Let's say I have a Customer class which has a 1:N relationship to his purchases, so for ORM, I would do something like this: class Customer { int id; List<Purchase> purchases; // also include all the usual, firsname, lastname, etc int getId(); setId(); List getPurchases(); setPurchases(); } class Purchase { int id; // purchaseName, date, etc... setId(); int getId(); } So to get the purchases for a particular customer, using ORM, I would so something like: Customer c = ORMManager.load(c, customerid); then I would do ...

Go Back   Application Development Forum > Framework and Interface Programming > JDBC JAVA

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 01-11-2006, 01:51 PM
Tom
Guest
 
Default modelling--DAO vs ORM

Hi, quick question about accessing the persistence layer, in particular
using DAO vs. using ORM. Let's say I have a Customer class which has a 1:N
relationship to his purchases, so for ORM, I would do something like this:

class Customer {
int id;
List<Purchase> purchases;
// also include all the usual, firsname, lastname, etc
int getId();
setId();
List getPurchases();
setPurchases();
}

class Purchase {
int id;
// purchaseName, date, etc...

setId();
int getId();

}

So to get the purchases for a particular customer, using ORM, I would so
something like:
Customer c = ORMManager.load(c, customerid);
then I would do
List p = c.getPurchases();
to get the purchases.

Now, for the DAO pattern, I would do this instead:
List p = PurchasesDAO.getPurchasesByCustomer(customerid);
so then I would not even need a reference to the list of purchases in the
Customer class...

SO, my question is, it seems to me that the persistence layer should not
dictate the modelling of the business objects, yet this seems to contradict
that. What would you suggest? If using the DAO pattern it seems like all
business objects would have no references to any other business objects.

-Tom



Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:05 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.