I noticed that our senior developer uses following code for retrieving entity by ID:
@Override
public Source get(Long id) {
Session session = getSession();
if( session == null )
session = sessionFactory.openSession();
final Source source = (Source)session.load(Source.class, id);
Hibernate.initialize(source);
return source;
}
What is benefit of this code?
Why not simply writing
return (Soruce) getSession().get(Source.class, id);