1

我以前用过AnnotationConfiguration,但现在已弃用

AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(Product.class);
factory = cfg.buildSessionFactory();

所以现在推荐使用Configurationinsted,但还是会报错: 配置.

现在如何建立会话工厂?

4

2 回答 2

2

所以你正在使用一些相当新的版本,也许是 4.0.0.CR4?如果是这样,请检查 buildSessionFactory 的 Javadoc,它会告诉您以下内容:

 @deprecated Use {@link #buildSessionFactory(ServiceRegistry)} instead

不知道建议更换工作,从未使用过。

于 2011-10-16T15:41:48.853 回答
1

org.hibernate.cfg.Configuration.buildSessionFactory() 就我所见没有被弃用:

http://docs.jboss.org/hibernate/core/3.5/javadoc/org/hibernate/cfg/Configuration.html#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 漏报了吗?

于 2011-10-16T15:35:51.030 回答