ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Huy <huym...@swiftdsl.com.au>
Subject Re: Flexible ResultMaps (Again)
Date Sat, 05 Feb 2005 22:26:12 GMT
Vic Cekvenich wrote:
> Huy wrote:
> 
>>
>>
>> I see what you mean but I need my domain objects because my apps are 
>> used by different clients with different databases with different 
>> schemas (similar but not exact; it's a legacy thing). The domain 
>> objects help me to keep all my other layers independent of the 
>> database schema. I know I can do "select column as blah" but I really 
>> don't like doing this in all my selects (it could get error prone).
>>
>> I really do believe that resultmaps is required for my situation. I 
>> just think it's a good idea to make it just that little bit more 
>> flexible.
>>
>> . However, unless you can help me overcome the problem above, I can't 
>> see how I can use it effectively.
>>
> 
> So...  your domain object can be a Map, just like a bean, read 
> http://groovy.codehaus.org/Quick+Start
> Old:
> class person { // at domain level, we do not know if this is one or 2 
> tables, it's a logical enity; nothing phsycial
> get/setName{}
> get/setAddress{}
> }
> 
> New:
> Map person ....
> 
> person.get("name")
> person.get("address")
> 
> SAME THING, you'll get used to it to have a collections for a domain.

> Anytime you have a hard coded bean.. use a losley typed map. If you have 
> to make a custom map... no big deal**. I learned to let go using 
> actionscript, it was not easy.
> The 2nd thing that helped me let go of beans is CoR (commons chains)... 
> it allways uses Map as an argument.
> 
> **side benefit... if you need to add, remove coluns on view or sql... 
> less code.
> 
> .V
> (join us CB, the water is warm ;-) )

My problem is not so much the map usage, but the "name", and "address" 
keys. To do this effectively, I'd have to write my sql select statements 
with the "select column as keys" form which I really want to avoid. I 
think it would be more error prone to do it this way (because of it's 
flexibility), especially in a multideveloper environment. How would you 
make sure all columns are named consistently, especially between 
different databases with the different schemas ?

huy

Mime
View raw message