Hibernate Proxy initialization when accessing the identifier


I’m doing some testing regarding proxy initialization when accessing the identifier in Hibernate 5.3.0 final release.

As stated in this issue, according to JPA, a Proxy should be loaded even when accessing the identifier. But in my case, when I access to the id property of a Proxy it is not being initialized (which in fact is the behavior that I’m expecting)

But I just wanted to clarify if this is something configurable somehow, because as far as I understand from that issue, it seems that the Proxy should be initialized in this case also.

Thank you in advance!

You need to set the hibernate.jpa.compliance.proxy property to true.

Check out the user guide for more details.

Sorry, did not read that part…it is clear, thanks!