晕,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 的 merge和cascade="all-delete-orphan"要慎重合在一起使用的更多相关文章
- Hibernate【inverse和cascade属性】知识要点
Inverse属性 Inverse属性:表示控制权是否转移.. true:控制权已转移[当前一方没有控制权] false:控制权没有转移[当前一方有控制权] Inverse属性,是在维护关联关系的时候 ...
- Save()saveOrUpdate()Hibernate的merge()方法
Save save()方法能够保存实体到数据库,正如方法名称save这个单词所表明的意思.我们能够在事务之外调用这个方法,这也是我不喜欢使用这个方法保存数据的原因.假如两个实体之间有关系(例如empl ...
- Hibernate Session中的save(),update(),delete(),saveOrUpdate() 细粒度分析
Hibernate在对资料库进行操作之前,必须先取得Session实例,相当于JDBC在对资料库操作之前,必须先取得Connection实例, Session是Hibernate操作的基础,它不是设计 ...
- Hibernate - lazy, fetch, inverse, cascade
Inverse是hibernate双向关系中的基本概念.inverse的真正作用就是指定由哪一方来维护之间的关联关系.当一方中指定了"inverse=false"(默认),那么那一 ...
- Hibernate中inverse、cascade的说明
一: 前沿:刚刚学习hibernate时,对于inverse很是纠结,不知道什么时候该用什么时候不该用,在网上找了一些资料,说的也很含糊,我都不知道如果写了"inverse=true&quo ...
- Hibernate的merge与update方法的区别
今天做了个测试,写了个测试用例来看看merge与update时控制台打印出来的日志有什么不一样.实体bean很简单,就id和name两个字段,接下来分别给出以下几种测试情形的控制台日志内容: 1. 数 ...
- 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 原因是主表中还包含字表的数据, ...
- hibernate的merge()
映射文件中的主键如果用sequence序列,需要指定序列名,如果不指定,则会自动使用hibernate_sequence(需要自己创建) getCurrentSession()方法获得的session ...
- Hibernate注解开发示例
-------------------------------------------------------------------customer------------------------- ...
随机推荐
- 关于 jquery.showLoading 中 出现的 图标不在页面中间的问题
很多人喜欢 showLoading 因为 这个实在是太简单了直接 showLoading() hideLoading() 就可以解决这个问题. 今天我们就来看一下 这个插件里面的一个错误 或者说 ...
- armv7a-mediatek451_001_vfp-linux-gnueabi-gcc: directory: No such file or directory 编译error
release/vm_linux/output/hisense_android/mt5399_cn_android_JB/rel/obj/oss/source/arm_mali_ko/mali400- ...
- 利用Jquery实现http长连接(LongPoll)
参考:http://www.cnblogs.com/vagerent/archive/2010/02/05/1664450.html PS:为了满足 某些需要 实时请求的业务(PS:例如聊天室),我们 ...
- WebViewJavascriptBridge
上一篇文章介绍了通过UIWebView实现了OC与JS交互的可能性及实现的原理,并且简单的实现了一个小的示例DEMO,当然也有一部分遗留问题,使用原生实现过程比较繁琐,代码难以维护.这篇文章主要介绍下 ...
- [ecmall]Ecmall 后台添加模板编辑区
例如,想把品牌/index.php?app=brand页面做成可编辑的. 首先,找到后台admin\includes\menu.inc.php第61行 'template' => array( ...
- 设计模式之单例(singleton)设计模式代码详解
单例有两种:懒汉式和饿汉式 /** * 懒汉式的单例模式 * 这种单例模式如果采用到多线程调用该方法,有可能会产生多个实例,原因是: * 当线程一进入了①处,此时轮到线程二的时间片,线程二也来到①处, ...
- 【HDU 1542】Atlantis 矩形面积并(线段树,扫描法)
[题目] Atlantis Problem Description There are several ancient Greek texts that contain descriptions of ...
- 【POJ 1741】 Tree (树的点分治)
Tree Description Give a tree with n vertices,each edge has a length(positive integer less than 100 ...
- Multiplication Puzzle
题目大致意思是:一个整数序列包含N个1~100的整数(3<=N<=100),从中取出一个数并和相邻两边的整数相乘,依次进行下去直到只剩下首尾两个数为止,求最终的得到的和的最小值.两边的数不 ...
- SPRING IN ACTION 第4版笔记-第三章ADVANCING WIRING-004-消除BEAN自动装配的歧义@QUALIFIER及自定义注解
一. The @Qualifier annotation is the main way to work with qualifiers. It can beapplied alongside @Au ...