I'm wondering how persistence of nested business objects should be handled.
For example, lets assume I have an (oversimplified) class design as follows:
Employee
| |
Address Name
In other words, an Employee class which is composed of both an Address and Name class. Address is a discrete class which can be saved independently of Employees (eg. Customer class also contains an Address). Per best practice, I have a DAO that only concerns itself with loading and saving Address objects:
class AddressDAO{
public static void save(Address addr){
//save address object
}
public static void delete(Address addr){
//delete address object
}
public static void add(Address addr){
//add address object
}
public static Address get(
String key ){
//get address object
}
}
I similiary have an EmployeeDAO class that laods/saves Employee objects. My question: is it appropriate to simply call AddressDAO.save from EmployeeDAO.save? Is there a cleaner approach?
[ November 06, 2008: Message edited by: Mitch Hartner ]
[ November 06, 2008: Message edited by: Mitch Hartner ]