According to my understanding in hibernate (please confirm)
1- You have to session.close()
if you get it by getSessionFactory().openSession()
I was also trying to understand the point: save() can perform Insert operation outside transaction boundary so I did something like this
SessionFactory factory = new Configuration().configure()
.buildSessionFactory();
Session session = factory.openSession();
session.save(user);
session.close();
But data not inserted in database.So I again tried this and now it worked for me and data inserted sucessfully:
in configuration file:
true
and in java code:
SessionFactory factory = new Configuration().configure()
.buildSessionFactory();
Session session = factory.openSession();
session.save(user);
session.flush();
session.close();