Is it possible in myBatis 3 to map a single result to multiple objects, ensuring that the objects all reference the same instance? Is there an example of this I could reference?
Updated to add more detail:
For instance, let's say I store information regarding Contact
s for my application in my DB. I want to know if it's possible to use myBatis to map the same instance of a contact to, say, a Listing
class, which holds a Contact
:
public class Listing {
private Contact myContact;
//getters & setters...
}
as well as to a ContactsHolder
class, which also holds a Contact
:
public class ContactsHolder {
private Contact aContact
//getters & setters...
}
I need the object that is mapped by myBatis to both the Listing
and ContactsHolder
classes to be the same instance. Is this possible?