我以前用过AnnotationConfiguration
,但现在已弃用
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(Product.class);
factory = cfg.buildSessionFactory();
所以现在推荐使用Configuration
insted,但还是会报错:
.
现在如何建立会话工厂?
我以前用过AnnotationConfiguration
,但现在已弃用
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(Product.class);
factory = cfg.buildSessionFactory();
所以现在推荐使用Configuration
insted,但还是会报错:
.
现在如何建立会话工厂?
所以你正在使用一些相当新的版本,也许是 4.0.0.CR4?如果是这样,请检查 buildSessionFactory 的 Javadoc,它会告诉您以下内容:
@deprecated Use {@link #buildSessionFactory(ServiceRegistry)} instead
不知道建议更换工作,从未使用过。
org.hibernate.cfg.Configuration.buildSessionFactory() 就我所见没有被弃用:
http://www.docjar.com/html/api/org/hibernate/cfg/Configuration.java.html
http://docs.jboss.org/hibernate/core/3.6/quickstart/en-US/html_single/
您确定不只是 Eclipse 漏报了吗?