Skip to content

Avoid nested DiffIgnored ValueObject being compare - #443

Merged
bartoszwalacik merged 2 commits into
javers:masterfrom
hank-cp:master
Oct 23, 2016
Merged

bartoszwalacik merged 2 commits into
javers:masterfrom
hank-cp:master

Conversation

@hank-cp

@hank-cp hank-cp commented Oct 17, 2016

Copy link
Copy Markdown
Contributor

Set gsonBuilder exclusionStrategies to avoid nested ValueObject circular reference.

@bartoszwalacik

Copy link
Copy Markdown
Member

why this strategy? javers doesn't serialize user's domain objets

@hank-cp

hank-cp commented Oct 19, 2016

Copy link
Copy Markdown
Contributor Author

Sorry, I didn't explain this issue clear enough. The problem is not about comparison, but about committing against MongoRepository. I add a few test case, hope that would explain the problem.

@bartoszwalacik

bartoszwalacik commented Oct 19, 2016 •

Copy link
Copy Markdown
Member

interesting, so, it's more gson problem than javers issue

@bartoszwalacik

Copy link
Copy Markdown
Member

you have a wrong mapping for CrossReferenceObjectA.
Obviously, this is a complext object so you should map it as ValueObject (not Value)
It's enough to remove @value ann, see
7ee9f6d

@bartoszwalacik bartoszwalacik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@hank-cp

hank-cp commented Oct 22, 2016

Copy link
Copy Markdown
Contributor Author

@bartoszwalacik Actually I do need to mark CrossReferenceObjectA/B as @Value, three reasons in my thought:

  1. In my case, CrossReferenceObjectA/B are very general, fundamental class, most of other business class will refer them, and they change quite a lot and often.
  2. These objects basically have a little bit complex, cross reference relation graph, according to my observation, committing them as @ValueObject, the javers repository size will be glowing very fast, a little bit out of control.
  3. I have to implement CustomPropertyComparator for these classes so it could compare by my custom algorithm rather than Javers general comparison algorithm. I think this will required @Value or JaversBuilder.javers().registerValue() (correct my if I am wrong).

@bartoszwalacik

Copy link
Copy Markdown
Member

Ok, makes sense, if @value fits better to your model then you should be able to choose it. Give me a while and I will merge

@bartoszwalacik
bartoszwalacik merged commit c473296 into javers:master Oct 23, 2016
@bartoszwalacik

Copy link
Copy Markdown
Member

released in 2.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants