Featured Post

Event Sourcing Video from Michael Ploed

Event Sourcing I want to share a great video I found few days ago that describes very well what Event Sourcing is.

Tuesday, April 14, 2015

EntityManager FIND vs GETREFERENCE

The main difference between find and get methods of EntityManager is that:
  • EntityManager find: return an object according to the fetch policy.
  • EntityManager getReference: return an hollow object. This object is lazy initialized, it only has the primary key populated.

The main difference is that EntityManager#getReference method is useful in the situation you need only the primary key of the requested object. An possible example is when you have to use the hollow object as part of an insert statement where only the reference of that object is useful.

No comments :

Post a Comment