title: Spring Hibernate SessionFactory
body: <p>How do you create a SessionFactory using the java config?</p>
  
  <pre><code>@Bean
  public SessionFactory sessionFactory(){
      AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
      sessionFactoryBean.setConfigLocation(new ClassPathResource("hibernate.cfg.xml"));
      return sessionFactoryBean.getObject();
  }
  </code></pre>
  
  <p>This doesnt work for some reason...it always returns null.</p>