commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Spencer <fizn...@hotmail.com>
Subject RE: BeanUtils copyProperties with null Date
Date Sun, 05 Oct 2008 10:57:51 GMT
Thanks very much for all the help guys. Hanson - I have looked at beanlib already, as my goal
here is populating DTOs from Entity beans and vice versa using hibernate. I attempted to get
something working with beanlib-hibernate but unfortunately due to the lack of documentation
I gave up and tried with BeanUtils - I could not get the hibernate2dto() methods working correctly.
However, the BeanPopulator has done the trick here - so thanks again.

I like the look of Morph - great documentation here. If I get any time I will give it a go.
The main problem I am having is specifying how deep in the object graph that my assemblers
should go, and how to not overwrite existing entities in the database that are associated
separately to the entity graph I am persisting. Bloody pain in the neck!

Thanks again,

Tom



> Date: Fri, 3 Oct 2008 12:32:22 -0700
> From: gudnabrsam@yahoo.com
> Subject: Re: BeanUtils copyProperties with null Date
> To: user@commons.apache.org
> 
> 
> --- Hanson Char <hanson.char@gmail.com> wrote:
> 
> > Or as a comparison, you can achieve the copying via
> > BeanPopulator of
> > beanlib, and it would just work.  See sample code
> > below.
> > 
> >  
> >
> http://sourceforge.net/project/showfiles.php?group_id=140152
> > 
> > Cheers,
> > Hanson
> > 
> > import java.util.Date;
> > 
> > import net.sf.beanlib.provider.BeanPopulator;
> > 
> > public class Bean1Bean2Main {
> >     public static void main(String...args) {
> >         Bean1 b1 = new Bean1();
> >         Bean2 b2 = new Bean2();
> > 
> >         BeanPopulator.newBeanPopulator(b1,
> > b2).populate();
> >         System.out.println(b1.getDate());
> >         System.out.println(b2.getDate());
> > 
> >         b1.setDate(new Date());
> >         BeanPopulator.newBeanPopulator(b1,
> > b2).populate();
> >         System.out.println(b1.getDate());
> >         System.out.println(b2.getDate());
> >     }
> > }
> > 
> 
> FWIW, the simplest approach to this in Morph
> (http://morph.sourceforge.net) should be:
> 
> Morph.copy(b2, b1);
> 
> -Matt
> 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@commons.apache.org
> > For additional commands, e-mail:
> > user-help@commons.apache.org
> > 
> > 
> 
> 
> 
>       
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 

_________________________________________________________________
Make a mini you and download it into Windows Live Messenger
http://clk.atdmt.com/UKM/go/111354029/direct/01/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message