0

I store an entity, then I need to execute native query (it's done through doWork), and for successful execution of the query record[s] that represent entity must exist in database (to be more precise, it must be available within the same transaction), so I guess calling flush is valid under such circumstances...

I got confused by hibernate documentation that says flush

must be called at the end of a unit of work, before committing the transaction and closing the session

Newer version http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e976 has example where flush is called in the loop.

Is it ok to call flush not just before committing ? If not, what is the alternative?

Thank you.

1 Answer 1

1

It is OK to flush at any time. See the documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.