좋아, 모든 단서를 가져 주셔서 감사합니다! 는 일 다음 :
내 응용 프로그램 코드에서 다음
public class HibernateUtil {
...
public static SessionFactory createSessionFactory(Properties p)
{
try {
// Create the SessionFactory from hibernate.cfg.xml
Configuration cfg = new AnnotationConfiguration().configure();
if (p != null)
cfg.addProperties(p);
return cfg.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
}
:
private void init() {
Properties p = new Properties();
p.setProperty("hibernate.hbm2ddl.auto", "create");
Session session = HibernateUtil.createSessionFactory(p)
.getCurrentSession();
session.beginTransaction();
session.getTransaction().commit();
session.getSessionFactory().close();
System.out.println("should be initialized....");
}