Valter Silva
Valter Silva

Reputation: 16656

What use in place of Annotations Configuration in Hibernate?

I used AnnotationConfiguration before but now is deprecated

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: configuration.

How build a session factory now ?

Upvotes: 1

Views: 459

Answers (2)

Mikko Maunu
Mikko Maunu

Reputation: 42094

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.

Upvotes: 2

Shivan Dragon
Shivan Dragon

Reputation: 15219

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?

Upvotes: 1

Related Questions