NemesisMate

Untitled

Oct 3rd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. @SpringBootApplication
  2. public class Main {
  3.  
  4.  
  5.  
  6. @Autowired
  7. private EntityManagerFactory entityManagerFactory;
  8.  
  9. @Bean
  10. public SessionFactory getSessionFactory() {
  11. if (entityManagerFactory.unwrap(SessionFactory.class) == null) {
  12. throw new NullPointerException("factory is not a hibernate factory");
  13. }
  14. return entityManagerFactory.unwrap(SessionFactory.class);
  15. }
  16.  
  17. public static void main(String[] args) {
  18. SpringApplication.run(Main.class, args);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment