I'm implementing several DAO classes for a web project and for some reasons I have to use JDBC.
Now I'd like to return an entity like this:
public class Customer{
// instead of int userId
private User user;
// instead of int activityId
private Activity act;
// ...
}
Using JPA user
and activity
would be loaded easily (and automatically specifying relations between entities).
But how, using JDBC? Is there a common way to achieve this? Should I load everiting in my CustomerDAO
? IS it possible to implement lazy initialization for referenced entities?
My first idea was to implement in my UserDAO
:
public void initUser(Customer customer);
and in my ActivityDAO
:
public void initActivity(Customer customer);
to initialize variables in customer
.