Coder Social home page Coder Social logo

Comments (7)

SQiShER avatar SQiShER commented on May 20, 2024

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.

SQiShER avatar SQiShER commented on May 20, 2024

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.

itsravi77 avatar itsravi77 commented on May 20, 2024

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.

SQiShER avatar SQiShER commented on May 20, 2024

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.

itsravi77 avatar itsravi77 commented on May 20, 2024

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.

itsravi77 avatar itsravi77 commented on May 20, 2024

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.

SQiShER avatar SQiShER commented on May 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.