ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: iBATIS: how to handle overloaded setters
Date Wed, 11 Jul 2007 12:38:30 GMT
No.  Overloaded setters are not supported and a bad idea (beaside breaking
the JavaBeans spec which the message already says).

Jeff Butler


On 7/11/07, wowiesy <ksy@i-manila.com.ph> wrote:
>
>
> given a domain object that has the following code
> (property/getter/setter):
>
> private BigDecimal amount;
>
> public BigDecimal getAmount(){
>   return this.amount;
> }
>
> public void setAmount(BigDecimal amt){
>   this.amount = amt;
> }
>
> public void setAmount(double amt){
>   this.amount = amt;
> }
> public void setAmount(float amt){
>   this.amount = amt;
> }
> public void setAmount(int amt){
>   this.amount = amt;
> }
>
>
> and the property is mapped into a column in a sqlmap as such:
>
> <result property="amount" column="amount" />
>
> I'm using Spring's SqlMapClientDaoSupport and upon initialization of the
> beans, I get this on the log output:
>
> 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.Benefit.  This breaks the
> JavaBeans specification and can cause unpredicatble results.
>
> And true enough, when I do an insert, and check the table itself, the
> right
> value is inserted. However, when I do a select, the right amount is
> returned.
>
> Any workarounds?
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/iBATIS%3A-how-to-handle-overloaded-setters-tf4061649.html#a11539435
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Mime
View raw message