遇到一个比较后悔莫及事情,使用了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 的 merge和cascade="all-delete-orphan"要慎重合在一起使用的更多相关文章

  1. Hibernate【inverse和cascade属性】知识要点

    Inverse属性 Inverse属性:表示控制权是否转移.. true:控制权已转移[当前一方没有控制权] false:控制权没有转移[当前一方有控制权] Inverse属性,是在维护关联关系的时候 ...

  2. Save()saveOrUpdate()Hibernate的merge()方法

    Save save()方法能够保存实体到数据库,正如方法名称save这个单词所表明的意思.我们能够在事务之外调用这个方法,这也是我不喜欢使用这个方法保存数据的原因.假如两个实体之间有关系(例如empl ...

  3. Hibernate Session中的save(),update(),delete(),saveOrUpdate() 细粒度分析

    Hibernate在对资料库进行操作之前,必须先取得Session实例,相当于JDBC在对资料库操作之前,必须先取得Connection实例, Session是Hibernate操作的基础,它不是设计 ...

  4. Hibernate - lazy, fetch, inverse, cascade

    Inverse是hibernate双向关系中的基本概念.inverse的真正作用就是指定由哪一方来维护之间的关联关系.当一方中指定了"inverse=false"(默认),那么那一 ...

  5. Hibernate中inverse、cascade的说明

    一: 前沿:刚刚学习hibernate时,对于inverse很是纠结,不知道什么时候该用什么时候不该用,在网上找了一些资料,说的也很含糊,我都不知道如果写了"inverse=true&quo ...

  6. Hibernate的merge与update方法的区别

    今天做了个测试,写了个测试用例来看看merge与update时控制台打印出来的日志有什么不一样.实体bean很简单,就id和name两个字段,接下来分别给出以下几种测试情形的控制台日志内容: 1. 数 ...

  7. Hibernate级联删除时:Cannot delete or update a parent row: a foreign key constraint fails异常

    在删除主表数据时,报了一个异常 Cannot delete or update a parent row: a foreign key constraint fails 原因是主表中还包含字表的数据, ...

  8. hibernate的merge()

    映射文件中的主键如果用sequence序列,需要指定序列名,如果不指定,则会自动使用hibernate_sequence(需要自己创建) getCurrentSession()方法获得的session ...

  9. Hibernate注解开发示例

    -------------------------------------------------------------------customer------------------------- ...

随机推荐

  1. 查看用户列表在Linux

    Linux下查看用户列表   原文地址:http://xiaod.in/read.php?77 俺的centos vps上面不知道添加了多少个账户,今天想清理一下,但是以前还未查看过linux用户列表 ...

  2. JSP页面的五种跳转方法

    ①RequestDispatcher.forward() 是在服务器端起作用,当使用forward()时,Servlet engine传递HTTP请求从当前的Servlet or JSP到另外一个Se ...

  3. iOS开发者计划(转)

    苹果对软件和开发者的管理十分严格,你只有加入了Apple Developer计划之后,才能将你的软件放到真机上运行或者发布到App Store上去.这种方法看似麻烦,但是却有效的解决了盗版和劣质软件充 ...

  4. ThinkPHP学习手记——环境搭建

    怀着激动的心情打开了thinkPHP的文档,开启了第一次php框架学习. 下载 ThinkPHP最新版本可以在官方网站(http://thinkphp.cn/down/framework.html) ...

  5. django入门教程(下)

    在两篇文章帮你入门Django(上)一文中,我们已经做了一个简单的小网站,实现了保存用户数据到数据库,以及从后台数据库读取数据显示到网页上这两个功能. 看上去没有什么问题了,不过我们可以让它变得更加完 ...

  6. 【POJ 3167】Cow Patterns (KMP+树状数组)

    Cow Patterns Description A particular subgroup of K (1 <= K <= 25,000) of Farmer John's cows l ...

  7. iOS开发UI篇—UITableviewcell的性能问题

    iOS开发UI篇—UITableviewcell的性能问题 一.UITableviewcell的一些介绍 UITableView的每一行都是一个UITableViewCell,通过dataSource ...

  8. PorterDuff及Xfermode初识

    图像合成,是将两幅退昂放在一起的动作,它使得我们能够同时看到两幅图像的特征. 我们可以首先在Canvas对象上绘制一个位图对象,然后再相同的Canvas对象上绘制第二个位图对象的方式来实现合成.不过这 ...

  9. Android用户界面 UI组件--TextView及其子类(四) Chronometer计时器

    Chronometer是一个简单的定时器,你可以给它一个开始时间,并以此定时,或者如果你不给它一个开始时间,它将会使用你的时间通话开始.默认情况下它会显示在当前定时器的值的形式“分:秒”或“H:MM: ...

  10. Android 如何把一个 RelativeLayout或ImageView背景设为透明

    在项目中,需要把RelativeLayout 和  ImageView背景设置为透明,怎么实现呢?这里主要通过代码,请参阅以下关键代码: public ImageView imgDetail; pri ...