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?
"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
Just do this
import org.hibernate.cfg.Configuration;
and then change your code for this
sessionFactory = new Configuration().configure("/hib.cfg.xml").buildSessionFactory();
I use this code:
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
sessionFactory = new Configuration().configure().buildSessionFactory(serviceRegistry);
yes it is working for me-
Configuration cfg=new Configuration();
cfg.configure();
ServiceRegistry serviceregistry=new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry();
Session session=cfg.configure().buildSessionFactory(serviceregistry).openSession();