Предположим, вы используете аннотацию для сопоставления VO с таблицей БД. Вот пример кода для динамического получения Spring HibernateTemplate:
AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
//set annotated classes.
sessionFactoryBean.setAnnotatedClasses(new Class<?>[]{VO1.class,VO2.class});
Properties props = new Properties();
//put all your hibernate configurations here
props.setProperty("dataSource.show_sql", "true");
props.setProperty("dataSource.dialect", "org.hibernate.dialect.MySQL5Dialect");
....
sessionFactoryBean.setHibernateProperties(props);
//Create DataSource Dynamically
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(...);
dataSource.setUrl(...);
dataSource.setUsername(...);
dataSource.setPassword(...);
sessionFactoryBean.setDataSource(ds);
//tell sessionFactoryBean that you are ready.
sessionFactoryBean.afterPropertiesSet();
SessionFactory sessionFactory = sessionFactoryBean.getObject();
HibernateTemplate template = new HibernateTemplate();
template.setSessionFactory(sessionFactory);