In hibernate there are some things that we cannot do. the following are the two things,
- Use of session.flush()
- 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