You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by wowiesy <ks...@i-manila.com.ph> on 2007/07/11 14:35:07 UTC

iBATIS: how to handle overloaded setters

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.


Re: iBATIS: how to handle overloaded setters

Posted by Jeff Butler <je...@gmail.com>.
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 <ks...@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.
>
>