Suppose I programmatically create a AnnotationSessionFactoryBean and set the various properties correctly. How can I then extract the Hibernate SessionFactory, since all methods that pertain to creating the SessionFactory are protected?
AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
SessionFactory sessionFactory = sessionFactoryBean.newSessionFactory(); // Protected!!
Use
getObject(), after callingafterPropertiesSet():(
AnnotationSessionFactoryBeanimplementsFactoryBean<SessionFactory>)Be careful, though: by doing this, it becomes your responsibility to make sure the
SessionFactoryis closed when you’re finished with it.