How to map a myBatis result to multiple objects?

No, MyBatis isn't able to do that with standard result mapping. (at least to my knowledge). You could select the "Contact" object, then build a Listing and ContactsHolder manually with both of them referencing the Contact.

No, MyBatis isn't able to do that with standard result mapping. (at least to my knowledge). You could select the "Contact" object, then build a Listing and ContactsHolder manually with both of them referencing the Contact.

Or implement a custom ResultSetHandler. It's kind of a peculiar request, I'm not sure why you want the same instances shared across two objects like that. That's probably why no feature like this exists in MyBatis 3.

BTW, I was able to solve this using a myBatis plugin (pg. 17 of the User Guide) and intercepting the handleResultSets method in the ResultSetHandler class. I was able to add the same Contact instance contained in the result set to both my Listing and ContactsHolder classes.

– holic87 Oct 27 at 23:37 Good idea, I will update my answer to reflect. – Andy Pryor Oct 28 at 14:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions