Hibernate example without any deprecated API's
Create your hibernate application and write following logic in main method
and run your code.
Configuration cfg = new Configuration();
cfg.configure();
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
cfg.getProperties()).build();
SessionFactory buildSessionFactory = cfg.buildSessionFactory(serviceRegistry);
Session openSession = buildSessionFactory.openSession();
Transaction beginTransaction = openSession.beginTransaction();
====================== ============================
cfg.configure();
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
cfg.getProperties()).build();
SessionFactory buildSessionFactory = cfg.buildSessionFactory(serviceRegistry);
Session openSession = buildSessionFactory.openSession();
Transaction beginTransaction = openSession.beginTransaction();
====================== ============================
create your bean class object . example -
Employee e=new Employee();
e.setId(103);
e.setAge(1011);
e.setName("rahul");
e.setPhone("2374234");
e.setId(103);
e.setAge(1011);
e.setName("rahul");
e.setPhone("2374234");
=============================================================
openSession.save(e);
beginTransaction.commit();
openSession.save(e);
beginTransaction.commit();
Comments
Post a Comment