Hi,
I am new in using hibernate and found an article related to "Open Session in View" pattern and have somes questions.
http://www.hibernate.org/43.html
1. Can I lock the records (by select for update) when the first request arrived on the server, and then display the data on the page, after user updated the data and click submit, I update the records and commit the transaction?
2. Does the impact of currentSession.getTransaction().commit() in the HibernateSessionConversationFilter same as the database transaction commit? e.g. the data are persisted in database.
3. I read the book Java Persistence with Hibernate (REVISED EDITION OF HIBERNATE IN ACTION) and it mention the sequence of the Interception of events to manage the lifecycle of a Session in figure 11.4 as follow
A. the first transaction (first request)
1. s = sf.openSession()
s.setFlushMode(MANUAL)
MSC.bind(s)
2. s.beginTransaction()
3. s = MSC.unbind()
4. commit()
B. the second transaction (second request)
5. MSC.bind(s)
6. s.beginTransaction()
7. s = MSC.unbind()
s.flush()
8. commit()
9. s.close()
Why it call commit() at the first transaction ? (in the step 4), Does this commit will persist the data to database and cannot be rollback on the second transaction?