Optimizing usage of Hibernate