Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. private static final SessionFactory ourSessionFactory;
  2. final Session session;
  3. static {
  4. try {
  5. Configuration configuration = new Configuration();
  6. configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
  7. configuration.configure();
  8. ourSessionFactory = configuration.buildSessionFactory();
  9. } catch (Throwable ex) {
  10. throw new ExceptionInInitializerError(ex);
  11. }
  12. }
  13.  
  14. public static Session getSession() throws HibernateException {
  15. return ourSessionFactory.openSession();
  16. }
  17.  
  18. public DataModule() {
  19. session = getSession();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement