Found the problem.

Apparently the object I was passing into copyProperties() did some
initializations in it's constructor (notably of the Map that was getting
blown away).

And the destination object that comes out of copyProperties() is not
precisely the same one as the one that got passed in. Or at least the
constructor seems to have been called again.

Should I submit a bug against copyProperties()? I can't decide how bad of an
idea that constructor initialization was..., but it seems that
copyProperties should be able to handle it.



> -----Original Message-----
> From: Joe Germuska [mailto:[EMAIL PROTECTED]
> Sent: Sunday, March 13, 2005 2:24 PM
> To: Joe Hertz; 'Struts Users Mailing List'
> Subject: Re: BeanUtils hates me...
> 
> At 2:15 PM -0500 3/13/05, Joe Hertz wrote:
> >I'm sorry about how lame this question seems. I'm staring quite stunned
> at
> >what I'm seeing in my debugger right now, and I'm hoping someone can
> explain
> >the behavior.
> >
> >Using Struts 1.2.4 (BeanUtils 1.7).
> >
> >I have two objects: A UserEntity and a User. The User is a subclass of
> >UserEntity.
> >
> >I call PropertyUtils.copyProperties(user, userEntity) and I'm watching a
> map
> >that was an element of the user object (and not of the userEntity)
> getting
> >blown away (almost as if the User Object itself was getting
> reconstructed).
> >
> >Why does this happen? (I can post to commons-user if I absolutely have
> to,
> >but I'm hoping someone can explain this...
> 
> Perhaps unintuitively, the order of arguments to copyProperties are
> (dest, orig) i.e. (to, from)
> http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanuti
> ls/BeanUtils.html#copyProperties(java.lang.Object,%20java.lang.Object)
> 
> So, by your example, user should be having all its properties set
> according to their equivalent values in userEntity.
> 
> joe
> --
> Joe Germuska
> [EMAIL PROTECTED]
> http://blog.germuska.com
> "Narrow minds are weapons made for mass destruction"  -The Ex



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to