Hello,

I am working with a 103-column table that tracks a variety of information
for a provider. Rather than modeling this as a single class with 103
attributes, I have defined a top-level class that contains a few core
provider attributes, and "subject-area" classes that group disjoint subsets
of attributes by domain ( e.g. Financial, Metrics, Demographics). The top
level bean contains an attribute for each of these "subject-area" classes.

My problem lies in effectively using iBatis to populate this structure from
a table row. My current approach is to use a custom type handler to populate
the subject area bean. The example below shows how I am populating the
"metrics" attribute in the resultMap of the top-level provider class.

   <result property="metrics"
           column="QT_ETHR_AVLB_RSTR"
           typeHandler="
com.cgi.wasacwis.typehandlers.ProviderMetricsTypeHandler"/>

The metrics attribute is actually a "subject-area" class that holds ~20
attributes from the row. The custom type handler, ProviderMetricsTypeHandler ,
contains code for creating and populating the fields. To illustrate, I have
included the method "getResult" below:

    private ProviderMetrics getResult(ResultSet r) throws SQLException {
        ProviderMetrics result =
WasacwisFactory.eINSTANCE.createProviderMetrics();

        result.setEitherAvailableRestricted        (r.getLong
("QT_ETHR_AVLB_RSTR"));
        result.setEitherProviderRestricted         (r.getLong
("QT_ETHR_PRVD_RSTR"));
        result.setFemaleAvailableRestricted        (r.getLong
("QT_FEML_AVLB_RSTR"));
        result.setFemaleProviderRestricted
(r.getLong("QT_FEML_PRVD_RSTR"));

        result.setMaleAvailableRestricted        (r.getLong
("QT_MALE_AVLB_RSTR"));
        result.setMaleProviderRestricted        (r.getLong
("QT_MALE_PRVD_RSTR"));
        result.setProviderParticipantsUnder18     (r.getLong
("QT_PRVD_PART_UND18"));
        result.setProviderParticipantsUnder2    (r.getLong
("QT_PRVD_PART_UNDR2"));
        result.setTotalAvailableBedCapacity
(r.getLong("QT_TOT_AVLB_BEDCAP"));

        result.setTotalAvailableRestricted        (r.getLong
("QT_TOT_AVLB_RSTR"));
        result.setTotalAvailableUnder18            (r.getLong
("QT_TOT_AVLB_UNDR18"));
        result.setTotalAvailableUnder2             (r.getLong
("QT_TOT_AVLB_UNDR2"));
        result.setTotalEitherPlaced                (r.getLong
("QT_TOT_ETHR_PLCD"));
        result.setTotalEitherReserved
(r.getLong("QT_TOT_ETHR_RSVD"));

        result.setTotalFemalePlaced                (r.getLong
("QT_TOT_FEML_PLCD"));
        result.setTotalFemaleReserved            (r.getLong
("QT_TOT_FEML_RSVD"));
        result.setTotalMalePlaced                 (r.getLong
("QT_TOT_MALE_PLCD"));
        result.setTotalMaleReserved                (r.getLong
("QT_TOT_MALE_RSVD"));
        result.setTotalPlaced                    (r.getLong("QT_TOT_PLCD"));

        result.setTotalPlacedUnder18            (r.getLong
("QT_TOT_PLCD_UNDR18"));
        result.setTotalPlacedUnder2                (r.getLong
("QT_TOT_PLCD_UNDR2"));
        result.setTotalProviderBedCapacity         (r.getLong
("QT_TOT_PRVD_BEDCAP"));
        result.setTotalProviderRestricted        (r.getLong
("QT_TOT_PRVD_RSTR"));
        result.setTotalReserved                    (r.getLong("QT_TOT_RSVD"));

        result.setTotalReservedUnder18            (r.getLong
("QT_TOT_RSVD_UNDR18"));
        result.setTotalReservedUnder2            (r.getLong
("QT_TOT_RSVD_UNDR2"));

        return result;
    }

Needless to say, I am writing the entire mapping for the provider metrics
class in Java, and this isn't making good use of iBatis. Can anyone suggest
a better strategy?

thank you,
Amin

Reply via email to