Hibernate Proxy initialization when accessing the identifier

Hello,

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!

Hello,
Quoting the hibernate user guide:

============================================================================
hibernate.jpa.compliance.proxy

See: JpaComplianceSettings.JPA_PROXY_COMPLIANCE

Since: 5.2.13

Default Value: JPA_COMPLIANCE

When enabled, this setting forces Hibernate to initialize the entity proxy when its identifier is accessed. Clearly, this setting is not recommended.

==========================================================================

But the interface JPACompliance is introduced in 5.3, so is this property taken into account in 5.2?