hi ansonau.....the line
Session hsession = HibernateContext.getSession
is used only in a transaction. It take the current transaction and it continue with it. After if i execute a session.close(), anyhow i have to wait the end of the transaction, if no no commit will be executed.
Then the line
SessionFactory factory = (SessionFactory)
create a new transaction and it will be closed by the close() method. No deployment descriptor or other thing can to be used to configure a transaction with hibernate.