• Dear Guest, Please do NOT forget to join our JAVA JOBS (ONLY) FACEBOOK GROUP to be aware of latest JAVA openings, and you may also post any JAVA related queries/jobs.

Hibernate (SessionFactory Configuration)

#1
SessionFactory sessionFactory =
new Configuration().configure().buildSessionFactory();

The above code gives me warning as buildSessionFactory is deprecated. I have Hibernate 4.0 version. I tried the below code:
Configuration config = new Configuration();
config.configure();
ServiceRegistry serviceRegistry= new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
SessionFactory sessionfactory = config.buildSessionFactory(serviceRegistry);
Session session = sessionfactory.openSession();
session.beginTransaction();
session.save(user);
session.getTransaction().commit();

it still doesnt work, any suggeestion.
 
Top