Java – project $$enhancerbycglib $$67a694bd appears in Hibernate
I have a document entity mapped many - to - one to the project entity
When I call document During getproject, in the debugger, I see some information about project $$enhancerbycglib $$67a694bd in the project field of the document object
How do I retrieve the actual project object?
Solution
What you see is hibernate proxy object, which enables hibernate to instantiate lazily
The first thing to ask yourself is whether you really want to access the original object Usually you'd better pretend that the proxy is your actual object and let hibernate do all the magic
If for some reason you really need the object itself (for example, if you need the exact type), the following code should work:
if (object instanceof HibernateProxy) { return ((HibernateProxy) object).getHibernateLazyInitializer().getImplementation(); }
You should know that the result of the code written above will provide you with a separate object that is no longer controlled by sleep, so the changes of the object will not be synchronized with the database!