2

I have entity classes and these entity classes implement their own equals() function, which just compares the Ids of the classes. Sadly, invoking equals() on a Hibernate proxy initializes it, which is completly useless in my case.

I use javassist as a proxy provider. Is there a way to modify the proxy generation code to not load the entity during an equals call, but instead does something else for me? Can I plug a custom proxy provider in Hibernate?

Please do not start a discussion on how equals should behave in Hibernate, this goes to far, there are different opinions on the topic, which I already know, and is not part of the question :).

1 Answer 1

1

It works if you override classes in the hibernate.jar, and providing your own Implementation of BasicLazyInitializer.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you elaborate on what exactly did you do to solve this problem, or point to any sort of howto manual? Thanks.
I added some more branches to the invoke function, to do something special in case of the equals funtion (and some other here not relevant functions). Oh, and I have a modified copy of the BasicLazyInitializer class on my classpath. The style might be bad, but the outcome was worth it :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.