Use @Configuration to inject SessionFactory.
extract db connection params to constructor of SessionFactory.
Small changes, to make code a little more clear