Hibernate Proxy Serialization and Client-side Receive

I lack an understanding of how the generated proxy class object (CGLib extended POJO) is passed to the remote client and still retains the ability to generate the Lazy Init. Exceptions

Does this mean that there is some kind of contract that all transferred objects of a class (proxy) will be restored again as a proxy? Where does the client get these generated classes? Sorry, but I totally don't understand.

+3
source share
2 answers

Since your client application now has a dependency on Hibernate. If your remote client does not have Hibernate in the classpath, you will receive NoClassDefFoundError. This demonstrates how opaque the abstraction is with Hibernate.

In principle, do not transfer objects over the network - send messages (which can then be used to create objects if you wish).

+2
source

Proxies are uninitialized. When they are transmitted, they lose Sessionwith which they were associated. Therefore, when an attempt is made to initialize them on the remote side, it logically fails.

You can fully initialize them before sending, using Hibernate.initialize(aProxy)

For more information check this answer .

+1

Source: https://habr.com/ru/post/1741639/


All Articles