How and when to use JPA’s getReference() Method
With the T getReference(Class<T> entityClass, Object primaryKey) and the T find(Class<T> entityClass, Object primaryKey) method, JPA’s EntityManager seems to provide 2 methods that do the same. Both of them seem to get an entity by its primary key from the database. There obviously is a difference between the 2 methods. An established and well-defined API…