I'm mapping a BigDecimal to iBATIS:
the domain object has a BigDecimal property amount, as you can see in the code, the getters and setters are present.Code:<resultMap class="paymode" id="paymode"> <result property="code" column="code" /> <result property="amount" column="amount" /> </resultMap>
Code:private BigDecimal amount; public void setAmount(BigDecimal amt){ this.amount = amt; } public BigDecimal getAmount(){ return this.amount; } public void setAmount(double amt){ this.amount = new BigDecimal(amt); } public void setAmount(float amt){ this.amount = new BigDecimal(amt); } public void setAmount(int amt){ this.amount = new BigDecimal(amt); }
however, as i've marked in bold/red, I've also overloaded the setter methods to be able to handle float, double and int values being plugged into the property. Because of this, I'm getting the following in the log output:
I understand the nature of the problem: that I should only have 1 setter method, however, how can i provide for float/double/int values being plugged in through the domain object?Code:2007-07-11 20:21:28,703 main [ERROR] com.ibatis.common.beans.ClassInfo - Illegal overloaded setter method for property amount in class pay.domain.Paymode. This breaks the JavaBeans specification and can cause unpredicatble results.


Reply With Quote