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 "Anusuri, Vijay M" <vi...@bankofamerica.com> on 2006/03/14 17:04:34 UTC

overloaded setter methods

 
Hi,  
 
I have two overloaded setter methods in DTO: one with Long Wrapper
parameter and another with long primitive.   This has been working fine
for several months.  But it stopped working recently and complaining
that "The error happened while setting a property on the result object".
I know what is happening here . Now  IBatis is started using setter
method with primitive long parameter.  Earlier It used use Long Wrapper
setter method.  What is the reason for this behavior?
 
 

Setter methods in DTO

  /**
   * @param parentAnalysisId The parentAnalysisId to set.
   */
  public void setParentAnalysisId(Long parentAnalysisId) {
    this.parentAnalysisId = parentAnalysisId;
  }

 

  /**
   * @param parentAnalysisId The parentAnalysisId to set.
   */
  public void setParentAnalysisId(long parentAnalysisId) {
    this.parentAnalysisId = new Long(parentAnalysisId);
  }

 

 
Thanks,
Vijay
 

Re: overloaded setter methods

Posted by Clinton Begin <cl...@gmail.com>.
Overloaded setter methods is a violation of the JavaBeans specification.  I
recommend you don't do it.  I also recommend you upgrade to JDK 1.5 if
possible, which will avoid the need for this entirely.

Even if you don't upgrade, overloading for this reason is a bad idea
IMHO....Java sucks for not having autoboxing until now, but dealing with it
using ad-hoc polypmorphism is probably not the best idea.  Honestly I'd
recommend just picking either the primitives or the object wrappers and
using them consistently.


Clinton


On 3/14/06, Anusuri, Vijay M <vi...@bankofamerica.com> wrote:
>
>
> Hi,
>
> I have two overloaded setter methods in DTO: one with Long Wrapper
> parameter and another with long primitive.   This has been working fine for
> several months.  But it stopped working recently and complaining that "The
> error happened while setting a property on the result object".   I know
> what is happening here . Now  IBatis is started using setter method with
> primitive long parameter.  Earlier It used use Long Wrapper setter method.
> What is the reason for this behavior?
>
>
>
> *Setter methods in DTO*
>
>    /**
>    * @param parentAnalysisId The parentAnalysisId to set.
>    */
>   public void setParentAnalysisId(Long parentAnalysisId) {
>     this.parentAnalysisId = parentAnalysisId;
>   }
>
>
>
>   /**
>    * @param parentAnalysisId The parentAnalysisId to set.
>    */
>   public void setParentAnalysisId(long parentAnalysisId) {
>     this.parentAnalysisId = new Long(parentAnalysisId);
>   }
>
>
>
> Thanks,
> Vijay
>
>