Our application needs a session object to communicate with the database when writing or reading data. As mentioned above, session objects can only be obtained through a session factory. Once we have constructed a session factory, opening a session is a quick and cheap operation. After we have finished using our session object, we must not forget to close the session and dispose it. We can use a
using statement to instruct the compiler to do this automatically for us.