On Tue, Sep 23, 2008 at 8:46 AM,  <[EMAIL PROTECTED]> wrote:
> Hi @all,
>
> as it seems, the PropertyUtils.copyProperties() as well as
> BeanUtils.copyProperties() only do a copy on "class-level".
> As I would like to reuse my copy-methods for an inherited
> class-structure I would like to ask if there is also a chance to do a
> "full"-object copy for inherited classes for all properties.
>
> ==========================================
> Example:
>
> public class Class1 {
>    private String attribute1;
> }
>
> public class Class2  extends Class1 {
>    private String attribute2;
> }
>
> public class Business {
>
>    public static copy(Class1 source, Class1 dest) {
>        PropertyUtils.copyProperties(source, dest)
>    }
> }
> ==========================================
>
> If I call Business.copy() with 2 instances of Class1, attribute1 is
> perfectly copied. But if I call the same method with 2 instances of
> Class2, only attribute1 is copied although I would also like to copy
> attribute2 as well. Any chance to do that?

It does do this - but looks like you have the parameters the wrong way
round, try

   PropertyUtils.copyProperties(dest, source)

> Furthermore I realized that enumerations are not copied, too. Is there a
> chance to copy the bean-instance including enumerations?

BeanUtils doesn't support JDK 1.5 features and it doesn't look very
likely it will do so since its pretty much in maintenance mode.

Niall

> Thanks for your help
>
> Thomas
>
>
>

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

Reply via email to