How can I have each call to save commit to the database?
I don’t want to, at each interation of a loop that I am in, to call commit and then restart the transaction.
for my application, just having a commit at each session.save is fine.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
EDIT: use a hibernate transaction:
Transaction handling with hibernate is detailed here:
In a servlet environment, hibernate recommends implementing a filter that starts a transaction when the request begins and ends it when the request is done. Sample code here:
If using JTA or EJB there are methods to work with the existing transaction context as described in the guide.
You could alternatively turn autoCommit mode on (which is disabled by default). Each statement would effectively be executed in a separate transaction. This is controlled by the “hibernate.connection.autocommit” option. More details here: