• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is saveOrUpdate() = update() + flush()?

 
T H Lim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a single table with 3 columns and 1 primary key. My use case is the same as mentioned here, https://www.hibernate.org/116.html#A22,

* the application loads an object in the first session
* the object is passed up to the UI tier
* some modifications are made to the object
* the object is passed back down to the business logic tier
* the application persists these modifications by calling update() in a second session

My observation was if I used update() to persist the modifications, I needed to call flush() method to persist the changes to the database. Whereas, if I used saveOrUpdate(), the changes were persisted in the database without flush(). What my simple understanding of saveOrUpdate() was if it was not there execute a SQL INSERT a new row otherwise SQL UPDATE the exisiting row with the new data. Is there anything else I not aware of?

I am using Wicket with org.springframework.orm.hibernate3.support.OpenSessionInViewFilter filter
Thanks

/lim/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic