It's possibile to adress an array by index in a sqlmap?
What I want is:
class A {
String[] foo = {"",""};
}
<resultMap id="someResultMap" class="A">
<result property="foo[0]" column="COLUMN_Y" />
<result property="fo开发者_如何学运维o[1]" column="COLUMN_X" />
</resultMap>
If I try I get:
There is no WRITEABLE property named 'foo[0]' in class 'A'
It's not possible to set value to an array by index in a sqlmap becuase iBatis uses setter to write the value. You should have setter for your property to use it in the sql map.
I would suggest to create property in your class for coulumnX and columnY. If you still want array to be used in the class, you can do some work around in your class like below.
class A {
String[] foo = {"",""};
String col1;
String col2;
//have getter and setter for col1 and col2
getFoo(){
foo[1] = getCol1();
foo[2] = getCol2();
return foo;
}
}
<resultMap id="someResultMap" class="A">
<result property="col1" column="COLUMN_Y" />
<result property="col2" column="COLUMN_X" />
</resultMap>
精彩评论