@Bean(destroyMethod = "shutdown")
@Autowired
public SessionFactory sessionFactory(final KeyedPoolableObjectFactory<String, Session> objectFactory) {
if (poolConfiguration == null) {
return new PooledSessionFactory(objectFactory);
} else {
return new PooledSessionFactory(objectFactory, poolConfiguration);
}
}