ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: help with ibatis 3 & objectwrapper, metaobject, etc.
Date Thu, 25 Feb 2010 02:35:11 GMT
What you're trying to do with ObjectWrapper is beyond its intended use. It
was never a consideration nor an intention for the ObjectWrapper to
instantiate objects.  ObjectWrapper was originally implemented to support
Scala types, and perhaps to support a custom property naming convention or
some other type (e.g. XML).

It was not intended to change or intercept the result object lifecycle or
override the result object entirely.

You can call it a design problem if you like.  But it's kind of like saying
Microsoft Word has a design problem because it isn't a very good
spreadsheet.

Clinton

On Wed, Feb 24, 2010 at 11:11 AM, Alexei Sokolov
<alexei.sokolov@gmail.com>wrote:

> 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?
>
> Thanks,
> Alex
>
>

Mime
View raw message