ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Sokolov <alexei.soko...@gmail.com>
Subject help with ibatis 3 & objectwrapper, metaobject, etc.
Date Wed, 24 Feb 2010 18:11:49 GMT
Hello everyone,

I'm new here, but either I don't understand ibatis internals or you have a
design problem. First, let me share my understanding of how ibatis handles
mapping of result sets to beans:

In *ResultSetHandler.getRowValue() method you create object instance using
objectfactory. then you create metaobject for it, which in turn creates
objectwrapper for that object instance. Then you use meta object methods to
populate property values on that object instance. During this process both
metaobject and objectwrapper essentially write values directly to the object
instance returned from object factory.

Now, consider this scenario: let's say my object wrapper constructs
intermediate object first and populates its values. Than when I'm done
processing a row, I want to create actual object instance that will be
returned to the client. How do I do this with the current implementation?
Ideally, it will be nice if ObjectWrapper had a method, say
'getPopulatedInstance()' and then line 179 in
FastResultSetHandler.getRowValue() (and other such places) could be
rewritten like

resultObject = foundValues ?
metaObject.getObjectWrapper().getPopulatedInstance() : null;

instead of

resultObject = foundValues ? resultObject : null;

In other words, it would be nice if objectwrapper is able to create new
instances in addition to being able to work as decorator.

Does it make sense at all?


View raw message