extended resultMaps, possibly a bug

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

extended resultMaps, possibly a bug

Herman Bovens
Hi,

In the MyBatis 3 documentation, the only reference I can find to extended resultMaps is in the context of discriminators.  Are they supported outside of that context?

I ran into the following problem:
I have a resultMap for an output parameter which has an association with a resultMap that extends a base resultMap.  In the final output object, I only get the properties of the base resultMap in the associated object.
By debugging MyBatis code I found out that an object is created for both the base and the extended resultMaps, and both are set on the <association> property of the root object.  At least in my case the object for the base map is set last, so it overwrites the object for the extended resultMap and I lose the values for the properties defined there.

I don't know if this just happens because I'm not using discriminators, or whether it is a general problem with (nested) extended resultMaps.   All I know is that it was working with iBatis 2.x.

Thanks
Herman
Reply | Threaded
Open this post in threaded view
|

Re: extended resultMaps, possibly a bug

Clinton Begin
Administrator
Can you post the SQL Map code  sample? 

On Wed, Jan 12, 2011 at 6:26 AM, Herman Bovens <[hidden email]> wrote:
Hi,

In the MyBatis 3 documentation, the only reference I can find to extended resultMaps is in the context of discriminators.  Are they supported outside of that context?

I ran into the following problem:
I have a resultMap for an output parameter which has an association with a resultMap that extends a base resultMap.  In the final output object, I only get the properties of the base resultMap in the associated object.
By debugging MyBatis code I found out that an object is created for both the base and the extended resultMaps, and both are set on the <association> property of the root object.  At least in my case the object for the base map is set last, so it overwrites the object for the extended resultMap and I lose the values for the properties defined there.

I don't know if this just happens because I'm not using discriminators, or whether it is a general problem with (nested) extended resultMaps.   All I know is that it was working with iBatis 2.x.

Thanks
Herman

Reply | Threaded
Open this post in threaded view
|

Re: extended resultMaps, possibly a bug

Herman Bovens
I can post a sample on Monday, but actually the problem appeared to be somewhat different and can easily be explained as follows:
- output parameter has resultMap B which extends resultMap A
- resultMap A has association property x with nested resultMap C
- resultMap B overrides association property x with nested resultMap D, which extends C

For association property x, first the extended map D's properties are loaded, then overwritten with C's properties (the base map).
Now I'm not sure the overriding of a property is at all supported when extending a resultMap.  But it worked in 2.5 (maybe by coincidence).

Thanks
Herman

2011/1/13 Clinton Begin <[hidden email]>
Can you post the SQL Map code  sample? 


On Wed, Jan 12, 2011 at 6:26 AM, Herman Bovens <[hidden email]> wrote:
Hi,

In the MyBatis 3 documentation, the only reference I can find to extended resultMaps is in the context of discriminators.  Are they supported outside of that context?

I ran into the following problem:
I have a resultMap for an output parameter which has an association with a resultMap that extends a base resultMap.  In the final output object, I only get the properties of the base resultMap in the associated object.
By debugging MyBatis code I found out that an object is created for both the base and the extended resultMaps, and both are set on the <association> property of the root object.  At least in my case the object for the base map is set last, so it overwrites the object for the extended resultMap and I lose the values for the properties defined there.

I don't know if this just happens because I'm not using discriminators, or whether it is a general problem with (nested) extended resultMaps.   All I know is that it was working with iBatis 2.x.

Thanks
Herman