ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrius Juozapaitis <andri...@gmail.com>
Subject Access to object metadata in mappers
Date Thu, 15 Apr 2010 09:03:55 GMT

I'm thinking of different ways to optimize my development cycle, which is
1. create domain object class
2. create mapper interface
3. create mapper xml
   -create result sets (though I usually just convert java's myProperty
notation to my_property in db)
   -create CRUD related operations (which, given my domain model, are pretty
much the same for each entity)

in quite a few cases, I find myself duplicating a lot of code in mapper
xmls. This makes it harder to maintain, and adding each new entity requires
additional xmls.

I had a few ideas on how to optimize that.
1. provide access to object metadata (class, method annotations,
reflectionion?) that can be used inside queries. This would allow me to
iterate through any number of properties, and generate quite a lot of sql
2. Extending one mapper xml from another. I imagine something like defining
my xxx.ProductMapper from xxx.ObjectMapper (which has CRUD and paging/search
operations defined), and just provide result sets and/or property lists in
the xxx.ProductMapper xml. This would work well with the extending of the
mapper interfaces (think abstract class - operations defined in base mapper,
with details specified in the extended one).
3. Parametrizing mapper xml files. Perhaps optional list of files to include
in the mapper xml, defined in the ibatis config file?

These are just ideas at the moment, but any of those things would make it
easier to write maintainable code, although a bit more complexity is


ps. I am aware of the existence of the ibator, but I just don't like the
idea of the generated code, when the information can be retrieved at

View raw message