hibernate session.save() does not reflect in database

后端 未结 9 2134
臣服心动
臣服心动 2020-12-08 14:30

According to my understanding in hibernate (please confirm)

1- You have to session.close() if you get it by getSessionFactory().openSession()

9条回答
  •  暖寄归人
    2020-12-08 14:57

    Whenever you carry out any unit of work on the database objects, Transactions have to be used. http://docs.jboss.org/hibernate/orm/4.0/hem/en-US/html/transactions.html shows why they are used and how they can be used. But, the key is to use a transaction object by calling session.beginTransaction() which returns a Transaction object. This will represent the unit of work carried out to the database.

提交回复
热议问题