Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate session.close() - will flush the data to database?

 
stshiva raaj
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Team,
I faced one problem, I am not using transaction but I have accessed persistent object. When I am trying to close the session, the updated data is reflected into database. Will session.close() flush the persistent data even I have not used transaction?

Code :
=====
try{
ElanTaskFolder folder=(ElanTaskFolder )session.get(ElanTaskFolder.class, folderId);
folder.setStartDate(new Date());
-------
-------
//I am not used flush or commit here. Just accessed db object and set the date only
} catch(Exception e{

} finally{
HibernateSessionFactory.closeSession();// The startDate will reflect current Date and Time in database? Actually, the current date is reflected in database. How it possible?
}

My conclusion, even close() is going to flush the data into db If i modify the persistent object
 
Volodymyr Lysenko
Ranch Hand
Posts: 512
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This probably explains session and transaction:
http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch13.html#transactions-demarcation
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic