Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate - AnnotationConfiguration deprecated

I am using Hibernate in version 3.6.0 and the AnnotationConfiguration is marked as deprecated.

Here is the the line in my HibernateUtil.java class:

sessionFactory = new AnnotationConfiguration().configure("/hib.cfg.xml").buildSessionFactory(); 

What's the replacement for AnnotationConfiguration?

like image 897
Tim Avatar asked Oct 15 '10 13:10

Tim


2 Answers

"All functionality has been moved to Configuration": http://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/cfg/AnnotationConfiguration.html

And here is Configuration:

http://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/cfg/Configuration.html

like image 77
Stas Avatar answered Oct 01 '22 18:10

Stas


Just do this

import org.hibernate.cfg.Configuration; 

and then change your code for this

sessionFactory = new Configuration().configure("/hib.cfg.xml").buildSessionFactory();  
like image 34
fuelusumar Avatar answered Oct 01 '22 16:10

fuelusumar