Let's say I have this Class:
Class A {
int id;
int[] b;
// Other properties
}
Class B {
int id;
// Other properties
}
The Class A has one-to-many relation with class B. I already have a service which caches B objects and return them on id.
Table schema looks something like this
Table a:
-------
int id,
prop1,
etc
Table a_to_b_map
----------------
int a_id,
int b_id
Now, how do I map this in iBatis?
Since, B objects are already cached, I want to get the list of ids into A objects and then use the service to enrich As.
Can someone suggest how to go about it?
Two possible alternative I can think of are:
- Create an inner class in A (AtoB map) and use a select query in iBatis config to populate this
- Inside the iBatis resultMap/select use another select to get the list of B ids (not too sure on how to do this in config)