Hi, sorry for my english, I speak spanish.
I have a question about generics.
I have an application running with ibatis 2.3.0, and I tried to 'generify'
some parts.
I introduce the "Keyable" interface:
public interface Keyable<K extends Key> {
public K getKey();
public void setKey(K key);
}
The Key is a simple abstract class:
public abstract class Key {
public Key() {
super();
}
}
Then, I declare my business object in this way :
public class Person implements Keyable<PersonKey> {
...
}
public class PersonKey extends Key {
private String code;
....
}
And declare the resultMap in this way:
...
<resultMap id="PersonResult" class="Person">
<result property="key.code" column="CODE" />
...
But i get this error:
Caused by: com.ibatis.common.beans.ProbeException: There is no WRITEABLE
property named 'code' in class 'com.pack.Key'
at
com.ibatis.common.beans.ClassInfo.getSetterType(ClassInfo.java:273)
at
com.ibatis.common.beans.GenericProbe.getClassPropertyTypeForSetter(GenericPr
obe.java:248)
...
My first (and naive, I think) solution is:
- add the getPersonKey() method to the Person class (which returns
explicitly the PersonKey)
- modify the resultMap, so that the property look like this:
property="personKey.code"
But is an ugly solution, and a lot of work.
And I want to retain the generics.
There is some better solution to this problem?
Thanks
Martín