R
Roger Varley
Hi
I've recently been looking at the DAO pattern. All the tutorials I have
seen so far deal with small, simple databases that maintain students or
CD collections and always build java objects that contain all the
fields in the database and the update function always updates all the
fields in the database whether they need updating or not.
However, "in the real world" a database will contain a mixture of
fields some of which are user maintainable, some of which are intended
to be maintained by other parts of the application. In most cases
(other than creation of new entries in the database) you will be
dealing with sub-sets of the data (maybe overlapping data sets as well)
and, within those subsets, some fields will be meant for updating, some
will be for display purposes only ( for example, a customer name may be
included to assist the user when maintaing fields). Implementing the
DAO pattern as shown in the tutorials becomes unweildy.
For example, the customer in a SAP R/3 environment is implemented by a
single master table with > 150 fields and several associated tables
that hold repeating data and some of these hold several rows per
customer and contain > 100 fields per row. So creating a java
representation of the full customer in every case and updating every
field when an update is issued is clearly not the way to do things.
How do people approach the DAO pattern in these circumstance? I'm
currently leaning towards having multiple customer objects each looking
at the database fields required for each piece of functionality, but
this seems to be a very messy way of doing things.
Regards
Roger
I've recently been looking at the DAO pattern. All the tutorials I have
seen so far deal with small, simple databases that maintain students or
CD collections and always build java objects that contain all the
fields in the database and the update function always updates all the
fields in the database whether they need updating or not.
However, "in the real world" a database will contain a mixture of
fields some of which are user maintainable, some of which are intended
to be maintained by other parts of the application. In most cases
(other than creation of new entries in the database) you will be
dealing with sub-sets of the data (maybe overlapping data sets as well)
and, within those subsets, some fields will be meant for updating, some
will be for display purposes only ( for example, a customer name may be
included to assist the user when maintaing fields). Implementing the
DAO pattern as shown in the tutorials becomes unweildy.
For example, the customer in a SAP R/3 environment is implemented by a
single master table with > 150 fields and several associated tables
that hold repeating data and some of these hold several rows per
customer and contain > 100 fields per row. So creating a java
representation of the full customer in every case and updating every
field when an update is issued is clearly not the way to do things.
How do people approach the DAO pattern in these circumstance? I'm
currently leaning towards having multiple customer objects each looking
at the database fields required for each piece of functionality, but
this seems to be a very messy way of doing things.
Regards
Roger