What use in place of Annotations Configuration in Hibernate?
I used AnnotationConfiguration
before but now is deprec开发者_如何学运维ated
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(Product.class);
factory = cfg.buildSessionFactory();
So now it's recommended to use Configuration
insted, but still get some error:
How build a session factory now ?
So you are using some pretty new version, 4.0.0.CR4 perhaps? If so, then check the Javadoc of buildSessionFactory and it will tell you following:
@deprecated Use {@link #buildSessionFactory(ServiceRegistry)} instead
No idea though is suggested replacement working, never used it.
org.hibernate.cfg.Configuration.buildSessionFactory() is not deprecated as far as I can see :
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/
Are you sure it's not just Eclipse that's miss-reporting?
精彩评论