I have this problem currently in iBATIS 2. I would prefer it be solved
in 2.4, but if it is more extensive in scope, then I wouldn't mind
seeing it pushed off to version 3.
Here are two classes which have two immutable interfaces:
interface A { class AImpl implements A {
String getName(); String getName();
} void setName(String name);
}
interface B { class BImpl implements B {
A getA(); A getA();
} void setA(A a);
}
At the moment iBATIS cannot create a BImpl because the get/setA methods
are returning the interface signature (not the concrete mutable class).
Even though iBATIS will call setA with an AImpl, it forgets the
implementation and cannot find setName on the returned object.
However, I think iBATIS CAN solve this problem!!! It's very easy: the
mapper needs to remember the concrete implementation injected, and cast
that when calling the setter.
The only way to currently solve this problem is by altering the class to
do this below. Here I have provided a separate set of properties just
for iBATIS object construction. It's not pretty but it's the only way
for iBATIS to "remember" the concrete type injected:
class BImpl implements B {
A getA();
void setA(A a);
AImpl getAImpl();
void setAImpl(AImpl);
}
Thoughts?
Paul