暈,hibernate 的 merge和cascade="all-delete-orphan"要慎重合在一起使用

weixin_34041003發表於2013-10-12

遇到一個比較後悔莫及事情,使用了hibernate 的 merge和cascade="all-delete-orphan" ,子表資料被刪除了。


1、使用cascade="all-delete-orphan" 來做級聯刪除操作,但是請慎重和getHibernateTemplate().merge(entity);引數一起使用,在使用這樣一個組合的時候,

hibernate會先執行getHibernateTemplate().merge(entity);執行一個更新或者是儲存操作,但是緊接著就會刪除 和這個表相關聯的資料。

Hibernate will auto remove all the relationships, 

我的擦。。。。,不解 啊,




2、

Hibernate: update WF_PLAN_BOOK set TRAIN_DEP=?, USER_ID=?, TRAINING_SON_TYPE=?, FORSECAST_CLASS_TIME=?, TRAINING_START_TIME=?, TRAINING_MAIN_TYPE=?, REVIEW_COST_ARREARS=?, RECIVED_DEP=?, TRAINING_GRANDSON_TYPE=?, TIME_PLAN=?, TEACHER_NAME=?, RMARK=?, CLASS_NAME=?, TRAINING_CLASS_NAME=?, COST_STANDARD=?, TRAINING_END_TIME=?, STUDENT_TYPE=?, MANAGER_PEOPLE=?, PLAN_PROJECT_NU=?, RUNID=?, NUMBER_OF_STUDENT=?, TOTAL_REVENUE=?, DEP_COST_RECEIVED=?, FINANCIAL_COST_RECEIVED=?, COST_ARREARS=?, APPRAISE_COST_RECIVED=?, APPRAISE_COST_ARREARS=?, REVIEW_COST_RECIVED=?, INCOME_COST=?, PAY_COST=?, TRAINING_COST_REMUNERATION=?, TRAINING_COST_BOOK=?, TRAINING_COST_DINING=?, TRAINING_COST_CONSUME=?, TOTAL_APPRAISE_PAY=?, APPRAISE_PAY_BOOK=?, APPRAISE_PAY_REMUNERATION=?, APPRAISE_PAY_DINING=?, APPRAISE_PAY_CONSUME=?, APPRAISE_PAY_SPOT=?, BOUNDARY_BENEFIT=?, GRADUATE_PEOPLE=?, MATERIAL=?, MATERIAL_STUDENT_PEOPLE=?, MATERIAL_GRADUATE_PEOPLE=?, BALANCE=?, APPRAISE_BALANCE=?, total_pay=?, unit_number=?, not_unit_number=?, unit_revenue=?, not_unit_revenue=?, class_number=?, day_person_number=?, plan_book_fileids=?, process_Flag=?, PROCESS_SIGN=?, MONTHLY=?, TRAINING_CARD_NUMBER=?, RECEIVED_TRAIN_COST=?, RECEIVED_REVIEW_COST=?, RECEIVED_APPRAISAL_COST=?, TOTAL_REVIEW_PAY=?, is_train_class=?, IS_CLOSED=? where MAINID=?
Hibernate: delete from TBL_FINANCIAL_PAY where FINANCIAL_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_CONSUMPTION_PAY where CONSUMPTION_PAY_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from TBL_STUDENT_INFO_PAY where STUDENT_ID=?
Hibernate: delete from WF_TEACHER_REMUNERATION where MAINID=?

 

相關文章