I have HibernateUtil class and pack of entities, servlets and jsp. What should I add to my code or hibernate config file to start create all H2 tables(according to my entities) right after deployment my war file on Tomcat, before first call(in my case this is login)
public class HiberUtil {
private static final SessionFactory sFactory = configureSessionFactory();
private static SessionFactory configureSessionFactory() {
Configuration cf = new Configuration();
cf.configure("hibernate.cfg.xml");
SessionFactory sf = cf.buildSessionFactory(new StandardServiceRegistryBuilder().applySettings(cf.getProperties()).build());
return sf;
}
public static SessionFactory getSessionFactory() {
return sFactory;
}
public static void closeSessionFactory(){
sFactory.close();
}
}