Refactor to use autowiring and fix transactional/hibernate session issue