2011-06-29 45 views
0

我有2個表如下休眠:在同一個表中的自我參照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 

任何幫助將appriciate ..

回答

0

直接從HIBERNATE JAVADOC複製,請谷歌你的例外,並先做一些研究。

當版本號或時間戳檢查失敗時指示Session包含陳舊數據(在使用具有版本控制的長事務時)引發。如果我們嘗試刪除或更新不存在的行,也會發生。

請注意,此異常通常表示用戶未能爲類指定正確的未保存值策略!