Quote:
I have a single flat table that needs need to get mapped into a small object model, ~6 levels.
I guess my first question is: Does it really need to to be mapped hierarchically? What if you mapped all your A's and then created a lot of functions to give you lists of the A's that you needed? Take an example of a table of locations in the world. It could look like this:
Code:
-- drop the tables first
drop table location;
-- create the tables
create table locations (
location_id identity
continent varchar(30)
,country varchar(30)
,region varchar(30)
,province varchar(30)
,city varchar(30)
,street varchar(30)
,street_number integer);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Elm', 1033);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Elm', 1034);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Elm', 1035);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Elm', 1036);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Elm', 1037);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Maple', 4);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Maple', 5);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Maple', 6);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Maple', 7);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Maple', 8);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Maple', 9);
insert into locations values (null, 'North America', 'USA', 'North', 'Michigan', 'Detroit', 'Maple', 10);
commit;
You could create functions to get lists of location objects based on criteria:
Code:
public interface LocationDao {
public List locationsInContinent(String continent);
}
You could also pass in a list and have a function that would filter based on a criteria.
I know it's not true object orientation, but it would avoid the multi-level mapping that just seems like a nightmare to me...