型ハンドラーへの Ibatis の複数列データマッピング。私が使用しているお金のオブジェクトには、値と通貨が必要です。複数の列を同じ callbacktype ハンドラにマップする方法は?
Java Money オブジェクト http://www.javapractices.com/topic/TopicAction.do?Id=13
public class MoneyTypeHandlerCallBack implements TypeHandlerCallback {
//The below works but problems it always defaults currency. I need to be able to get Currency as well to use
// new Money(value, currency ) constructor
@Override
public Object getResult(final ResultGetter getter) throws SQLException {
BigDecimal value = getter.getBigDecimal();
if (value == null) {
return null;
}
Money result = new Money(value); // I need to be able to do new Money (value, currency)
return result;
}
... implment other...
}
SomeView Bean 定義:
public class SomeView implements Serializable{
private String companyName
private Money netamount;
// .....geters and setters etc
}
SQLMAP 構成:
<sqlMap namespace="myspace">
<typeAlias alias="someView" type="com.my.view.someView" />
<resultMap id="some_detail_view" class="someView">
<result property="companyName" column="COMPANY" />
...
<result property="netamount" column="NET_AMT" />
<result property="netamountCurrency" column="NET_AMT_CURRENCY" />
</resultMap>
<select id="someView" parameterClass="java.util.Map"
resultClass="someView" resultMap="some_detail_view">
SELECT COMPANY, NET_AMT, NET_AMT_CURRENCY From......
</select>
</sqlMap>