struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Germuska <...@Germuska.com>
Subject Re: BeanUtils hates me...
Date Sun, 13 Mar 2005 19:23:52 GMT
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/beanutils/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            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message