You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Sumit S." <su...@virtusa.com> on 2003/11/11 14:05:16 UTC

ResultSetDynaClass etc...

The ResultSetDynaClass & ResultSetDynaBeans are a powerful way of encapsulating ResultSets in DynaClasses. However, when we need to transfer the data from such a DynaClass to a ValueObject (say a structs ActionForm), the PropertyUtils.copyProperties looks for a property name match.

So now my ActionForm attributes get tied to the DB Column names....and if at a later point in time, the column names are changed, it means a change in code.

One option is to store the mapping information in a simple configuration file and override the copyProperties to take this mapping info as an input parameter as well...

something like

copyProperties (Object dest, Object src, Map map)
{
    for each property in src
        read the value from source.
        get the corresponding property name in dest from the map
        set the property value in the dest
}

I have written a small class to do the above....
Is there a more elegant way of doing it.....The config might be XML or Text based which can be converted into Map objects & cached.

Thanks
Sumit