Add hibernate dependencies. Refactoring