Reputation: 306
I have read more information about these commands but didn't understand exactly what a right way to use these commands?.
I want to discover deeply the difference between clear()
, evict()
and close()
methods in details. As I know evict()
will clear particular object from session in hibernate and clear()
will clear all objects from session.
How to use them correctly? Thanks
Upvotes: 7
Views: 8728
Reputation: 2222
Approximately the definition of the commands:
Clear ()
: When this method get called inside transaction boundry then all objects which are currently associate with particular session will be disconnected / clean or no longer associate with that Session instance.
Therefore, after calling this method nothing will be performed on persistance layer or DB.
Evict()
: Removes the object from the session. This method is used to dissociate/disconnect the specified object from the session.
Close()
: Close session by calling session.close()
method, means End the session and releasing the JDBC Connection and clean up.
Examples of using these commands you can find here.
Upvotes: 5