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

遇到一个比较后悔莫及事情,使用了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=?

 

你可能感兴趣的:(Hibernate)