I have a class that looks like this. I need to populate it from two database tables, which are also shown below. Is there any preferred way to do this?
My thought is to have a service class to select a List<>
via a ResultSetExtractor
from a DAO. Then do a foreach
on that list, and select a List<>
of emails for the individual person via another ResultSetExtractor
, and attach it from with the foreach
loop.
Is there a better way, or is this as good as it gets?
public class Person {
private String personId;
private String Name;
private ArrayList<String> emails;
}
create table Person (
person_id varchar2(10),
name varchar2(30)
);
create table email (
person_id varchar2(10),
email varchar2(30)
);