休眠:在同一个表和不同的表中自引用FK



我有两个表,如下

historyQuestions
=====================
question_id bigint(2) PK
question_master_id bigint(2) fk references question_master(question_id)
parent_question_id bigint(2) fk references historyQuestions(question_id)
parent_answer_id bigint(2) fk references historyAnswers(answer_id)
historyAnswers
=====================
answer_id bigint(2) pk
question_id bigint(2) fk references historyQuestions(question_id)
answer_master_id bigint(2) fk references answer_master(answer_id)

现在我想使用hibernate 新插入记录

session.save(entityObj)

但它给了我

exception org.hibernate.StaleStateException

任何帮助都将被告知。。

直接从HIBERNATE JAVADOC复制,请先在谷歌上搜索您的异常并进行一些研究。

当版本号或时间戳检查失败时抛出,表示会话包含过时数据(当使用带有版本控制的长事务时)。如果我们尝试删除或更新不存在的行,也会发生这种情况。

请注意,此异常通常表示用户未能为类指定正确的未保存值策略!

最新更新