Fixing the Hibernate and updating the deprecated method