hibernate session.save() does not reflect in database

后端 未结 9 2156
臣服心动
臣服心动 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 15:21

    if there is DB manipulation operation then it should be in transaction
    if you call session.save(object)
    hibernate create bellow query only .
    select hibernate_sequence.nextval from dual
    so right code is here
    Transaction  t=session.beginTransaction();
    session.save(obect);
    t.commit(); should not forgot to commit.
    session.close();
    

提交回复
热议问题