How should I represent a FOREIGN KEY field in the database on the java data model class? Is it represented as an Array of object? Because I can't populate the entire Entity class with just one SELECT Query from the database, I'll then have to iterate through all the row of the FOREIGN KEY reffered table.
TABLE CLIENT
-- clientId (PRIMARY KEY)
-- clientName
-- clientPhoneNumber
-- clientBirthDate
TABLE ORDER
-- orderId (PRIMARY KEY)
-- orderDate
-- orderNumber
--clientId (FOREIGN KEY)
Should the Data Object of Client looks like that:
public class ClientData{
private int clientId;
private String clientName;
private String clientPhoneNumber;
private String clientBirthDate;
...
}
or this
public class ClientData{
private int clientId;
private String clientName;
private String clientPhoneNumber;
private String clientBirthDate;
private ArrayList<OrderData> orderList;
...
}
Aucun commentaire:
Enregistrer un commentaire