You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Paul Benedict <pb...@apache.org> on 2008/03/05 16:33:15 UTC

BeanUtils: dirty checking

This question is about BeanUtils 1.8.

Does any functionality exist to compare two beans of the same type to
determine whether (a) it is dirty and (b) a list/set of differences of
properties?

Paul

Re: BeanUtils: dirty checking

Posted by Paul Benedict <pb...@apache.org>.
I implement a lot of requirements where I must capture the difference of
entities. I've seen so much custom code for this kind of thing.

Paul

On Wed, Mar 5, 2008 at 9:44 AM, James Carman <ja...@carmanconsulting.com>
wrote:

> On 3/5/08, Niall Pemberton <ni...@gmail.com> wrote:
> > On Wed, Mar 5, 2008 at 3:33 PM, Paul Benedict <pb...@apache.org>
> wrote:
> >  > This question is about BeanUtils 1.8.
> >  >
> >  >  Does any functionality exist to compare two beans of the same type
> to
> >  >  determine whether (a) it is dirty and (b) a list/set of differences
> of
> >  >  properties?
> >
> >
> > Not at the moment, but I think theres an open JIRA ticket for this
> >  kind of thing somewhere:
> >
> >  http://commons.apache.org/beanutils/issue-tracking.html
>
> It might be nice to just provide a List<String> BeanUtils.diff(Object
> bean1, Object bean2) method which merely returns the properties that
> are different between the two beans (a meaningful equals method would
> have to be implemented for the property types of course).  Perhaps
> that should go in PropertyUtils?
>
> >
> >  I have a "modified lazy DynaBean" implementation that can track
> >  changes (you switch on/off the tracking as required) and you can get a
> >  list of modified properties and their current and original values.
> >  Works pretty well for us
> >
> >  Niall
> >
> >  >  Paul
> >  >
> >
> >  ---------------------------------------------------------------------
> >  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
>
>

Re: BeanUtils: dirty checking

Posted by James Carman <ja...@carmanconsulting.com>.
On 3/5/08, Niall Pemberton <ni...@gmail.com> wrote:
> On Wed, Mar 5, 2008 at 3:33 PM, Paul Benedict <pb...@apache.org> wrote:
>  > This question is about BeanUtils 1.8.
>  >
>  >  Does any functionality exist to compare two beans of the same type to
>  >  determine whether (a) it is dirty and (b) a list/set of differences of
>  >  properties?
>
>
> Not at the moment, but I think theres an open JIRA ticket for this
>  kind of thing somewhere:
>
>  http://commons.apache.org/beanutils/issue-tracking.html

It might be nice to just provide a List<String> BeanUtils.diff(Object
bean1, Object bean2) method which merely returns the properties that
are different between the two beans (a meaningful equals method would
have to be implemented for the property types of course).  Perhaps
that should go in PropertyUtils?

>
>  I have a "modified lazy DynaBean" implementation that can track
>  changes (you switch on/off the tracking as required) and you can get a
>  list of modified properties and their current and original values.
>  Works pretty well for us
>
>  Niall
>
>  >  Paul
>  >
>
>  ---------------------------------------------------------------------
>  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


Re: BeanUtils: dirty checking

Posted by Niall Pemberton <ni...@gmail.com>.
On Wed, Mar 5, 2008 at 3:33 PM, Paul Benedict <pb...@apache.org> wrote:
> This question is about BeanUtils 1.8.
>
>  Does any functionality exist to compare two beans of the same type to
>  determine whether (a) it is dirty and (b) a list/set of differences of
>  properties?

Not at the moment, but I think theres an open JIRA ticket for this
kind of thing somewhere:

http://commons.apache.org/beanutils/issue-tracking.html

I have a "modified lazy DynaBean" implementation that can track
changes (you switch on/off the tracking as required) and you can get a
list of modified properties and their current and original values.
Works pretty well for us

Niall

>  Paul
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org