Skip to content

Include or exclude properties for comparison #108

@ClaudioNazareth

Description

@ClaudioNazareth

Hello! I'll try to illustrate my problem. (Sorry for my bad english)

I need to compare two complex objects before upgrading them for logging the differences. To avoid errors like LazyInitializationException or having to carry all my lazy lists, i need to select which attributes should compare.

I saw the anotation @ObjectDiffProperty(excluded = true) but i can not use it in my project. Is there any annotation to mark a property as compare, in which the properties unannotated not be compared?

If I have an entity called USER who has a list of addresses. The address has several fields and I need exclude or include some of these fields. I tried as follows:

final ObjectDifferBuilder builder = ObjectDifferBuilder.startBuilding();
builder.inclusion().include().node(NodePath.with("addresses","streed"));
or
builder.inclusion().exclude().node(NodePath.with("addresses","number"));
final DiffNode node = builder.build().compare(user2, user1);
node.visit(new PrintingVisitor(usuario2, usuario1));

But that did not work.

I have make any mistakes?

Thx for help

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions