Java Hibernate:在同一个表和不同的表中自引用FK

Java Hibernate:在同一个表和不同的表中自引用FK,java,hibernate,Java,Hibernate,我有如下两张桌子 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 re

我有如下两张桌子

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复制,搜索您的例外情况并首先进行一些研究

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

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