Guest User

Untitled

a guest
Jan 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. private static SessionFactory buildSessionFactory() {
  2.  
  3. // Create the SessionFactory from hibernate.cfg.xml
  4. Configuration configuration = new Configuration();
  5. configuration.configure();
  6.  
  7. configuration.setProperty("hibernate.connection.url", myUrl);
  8. configuration.setProperty("hibernate.connection.username", myUser);
  9. configuration.setProperty("hibernate.connection.password", myPass);
  10.  
  11. serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
  12.  
  13. return configuration.buildSessionFactory(serviceRegistry);
  14. }
  15.  
  16. protected void startOperation() {
  17. session = HibernateUtil.getSessionFactory().openSession();
  18. tx = session.beginTransaction();
  19. }
  20.  
  21. configuration.setProperty("hibernate.hbm2ddl.auto", "create-drop");
Add Comment
Please, Sign In to add comment