/**
* Constructor to build the hibernate helper.
* @param namingStrategy the name strategy, if one is needed, null otherwise.
* @param interceptor the interceptor, if one is needed, null otherwise.
*/
public HibernateHelper(NamingStrategy namingStrategy, Interceptor interceptor) {
try {
configuration = new AnnotationConfiguration();
initializeConfig(namingStrategy, interceptor);
configuration = configuration.configure();
// We call buildSessionFactory twice, because it appears that the annotated classes are
// not 'activated' in the config until we build. The filters required the classes to
// be present, so we throw away the first factory and use the second. If this is
// removed, you'll likely see a NoClassDefFoundError in the unit tests
configuration.buildSessionFactory();
sessionFactory = configuration.buildSessionFactory();
} catch (HibernateException e) {
// LOG.error(e.getMessage(), e);
// throw new ExceptionInInitializerError(e);
LOG.warn("Failed to initialize HibernateHelper using hibernate.cfg.xml. "
+ "This is expected behavior during unit testing." , e);
e.printStackTrace();
}
}
HibernateHelper.java 文件源码
java
阅读 36
收藏 0
点赞 0
评论 0
项目:labviewer
作者:
评论列表
文章目录