Java / Hibernate - Write operations are not allowed in read-only mode

后端 未结 11 2201
迷失自我
迷失自我 2020-11-28 11:18

I\'ve been having an annoying exception a lot lately, and after some research on Google and this forum I still haven\'t found an answer that could solve my problem.

11条回答
  •  悲哀的现实
    2020-11-28 11:53

    Try to use this

    this.getHibernateTemplate().setCheckWriteOperations(false);
    

    Still if you are using hibernate4 and not able to update entity/table then you need to create session and need to do flush the session i.e.

    this.getHibernateTemplate().setCheckWriteOperations(false);
    Session session = this.getHibernateTemplate().getSessionFactory().openSession();
    session.saveOrUpdate(entityName,app);
    session.flush();
    session.close();
    

提交回复
热议问题