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...
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?
4 Answers
"All functionality has been moved to Configuration":
And here is Configuration:
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();