Please consider while using Hibernate

In hibernate there are some things that we cannot do. the following are the two things,

  1. Use of session.flush()
  2. Use of session.close()

We will be using the session.flush() method to flush the data in the session but in hibernate this method should not be used before commiting the transaction ortherwise it wont raise error in the current transaction, But if you want to do same type of transaction next time then it will raise a nullponiter exception.

The very pity thing in session.close method is it does not call the session.flush method internally. So do remember to call the flush method before calling the close method

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.