I created a program using Hibernate.
The program reaches the main function end, nevertheless the program is running.
I wonder if it happens when Sessio
I faced the same issue, the reason is we need to close the resources properly. try closing the resources in finally block
try{
Configuration cfg = new Configuration().configure("hibernate.cfg.xml");
sessionFactory = cfg.buildSessionFactory();;
session = sessionFactory.openSession();
transaction = session.beginTransaction();
session.save(person);
transaction.commit();
}catch(Exception e){
System.out.println("Exception occured. "+e.getMessage());
}finally{
if(session.isOpen()){
System.out.println("Closing session");
session.close();
}
if(!sessionFactory.isClosed()){
System.out.println("Closing SessionFactory");
sessionFactory.close();
}
}