What is the significance of entityamanager.getReference() other than creating proxy object?

getReference() function is useful for creating the proxy object.
If an entity having only id and collection field then find() method by default behave as getReference(). Then what will be the uses of getReference() in such case?

That’s not true. As explained in this article, the Proxy object is not the same as a Pojo.

The getReference() will create a Proxy and any further property access will trigger the SELECT query. So, if you plan on using the entity and access its property, it’s better to use find right from the start and avoid Proxy method invocations.

1 Like