Comments (7)
Here are some examples about exclusion, that should point you in the right direction. The one in line 48 seems like the most promising one for your scenario.
from java-object-diff.
However, I'm not sure you really want to diff the SessionFactory
. Maybe it would be better just to ignore the entire type.
from java-object-diff.
Thanks Daniel. Yes I would like to ignore whole of SessionFactory object. I did try to do it by setting the exclusion type to SessionFactoryImpl.class but it didn’t work.
from java-object-diff.
It has been ages since I've used Hibernate, so I'm just guessing here, but could it be that the SessionFactory
is not an instance of SessionFactoryImpl
but of SessionFactoryDelegatingImpl
?
from java-object-diff.
It’s other way. SessionFactoryImpl is implementation of SessionFactory. I noticed in your example “objectDifferBuilder.inclusion().exclude().type(ArrayList)”, Do we need to say ArrayList.class?
from java-object-diff.
Hi Daniel, I fixed the issue by adding following exclusions:
ObjectDiffer objectDiffer = ObjectDifferBuilder.startBuilding() .inclusion().exclude().propertyName("handler").and() .inclusion().exclude().propertyName("hibernateLazyInitializer").and() .build();
But interestingly, now I don't see it throwing exception if I remove those exclusions, nothing has changed as well. And I see these log entries:
2019-01-25 18:13:57 [http-nio-0.0.0.0-8899-exec-1] WARN d.d.d.c.CircularReferenceService - Detected circular reference in node at path /country/handler/session/delegate. Going deeper would cause an infinite loop, so I'll stop looking at this instance along the current path. 2019-01-25 18:13:57 [http-nio-0.0.0.0-8899-exec-1] WARN d.d.d.c.CircularReferenceService - Detected circular reference in node at path /country/handler/session/session. Going deeper would cause an infinite loop, so I'll stop looking at this instance along the current path. 2019-01-25 18:13:57 [http-nio-0.0.0.0-8899-exec-1] WARN d.d.d.c.CircularReferenceService - Detected circular reference in node at path /country/hibernateLazyInitializer/session/delegate. Going deeper would cause an infinite loop, so I'll stop looking at this instance along the current path. 2019-01-25 18:13:57 [http-nio-0.0.0.0-8899-exec-1] WARN d.d.d.c.CircularReferenceService - Detected circular reference in node at path /country/hibernateLazyInitializer/session/session. Going deeper would cause an infinite loop, so I'll stop looking at this instance along the current path.
Any reason what has changed?
from java-object-diff.
Glad it works now. It's hard to tell what has changed. Didn't Hibernate have some kind of mechanism to attach and detach objects from it? Maybe your object is in detached state and wasn't before? It's really hard to say without seeing your code. And even then it might be some strange little detail. Looking at the reported circular references I'm kinda worried, your object might not be the best target for the object differ. Especially hibernateLazyInitializer
and session
look like properties that just should not be part of the comparison. Maybe you can make it easier on yourself if you wrap your class in a facade that just exposes the important parts of your data.
from java-object-diff.
Related Issues (20)
- Javadoc build errors
- Is ObjectDiffer thread safe and non-stateful?
- Suggestion: Put element index in CollectionItemElementSelector HOT 3
- How to exclude map key HOT 1
- OSGi MANIFEST.MF is broken for version 0.95
- java.time.LocalTime not working
- How to get the difference between two simple objects? HOT 4
- java基本类型boolean比较有问题,只有ADD或者DELETE。其中EDIT出现不了 HOT 1
- compare wrongly returns UNTOUCHED
- How to apply diffs
- How to exclude property of a collection of specific type
- How to get diff of child Object ? HOT 1
- Differences in excluded fields in objects of a collection cause state of collection diff to be changed HOT 3
- Can't Find Setter For Property While Using lombok HOT 1
- Problem with circular references
- PrintingVisitor should print only the relevant fields of a CollectionItemElementSelector
- java8 LocalDateTime is not supported HOT 1
- llegalStateException: Couldn't find a differ for type: [Lorg.joda.time.DateTimeFieldType
- can add @ObjectDiffProperty use to class field?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-object-diff.