I'm currently developing an android application, and because i need to access a database, i've decided to use the dao pattern. Currently, i understand the concepts of this pattern.
In my app, i have my business objects. For example, let's consider the order and the payment objects. Let's assume that an order as a variable of the type payment. In the database, each record of the table orders will have a foreign key for the payments table, that keeps the associacion between the order and it's payment. The problem is, as dao's should be completely independent from each other, the OrderDao won't "know" the PaymentDao, so how can i instantiate a order object, with the corresponding payment instance in it? This is making me really confused... The OrderDao won't be able to return a order instance, because this instance needs a payment instance.. I could do some "tricks", like the OrderDao returns a instance with a payment initialized with only its id, and later in the business logic, grab that id and use the PaymentDao to retrieve the payment instance and set it to the previous order... But this doesn't sound that good..
How should this be done?
Just to make my explanation easy about the classes structure:
public class Order {
private int id;
private Payment payment;
......
}
public class Payment {
private int id;
....
}
The reason i'm not using any framework, is because in my database, i need some table that hold some strings translated.. For example, if we had a categories table, i would have a categories_i18n table, that for each record in the categories table, would have the corresponding translation in some languages..
Thanks in advance.