晕,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------------------------- ...
随机推荐
- UIPageControll - 图片格式
设置pageCon的显示风格: 1. 颜色 page.pageIndicatorTintColor = [UIColor redColor]; page.currentPageIndicatorTin ...
- Cocoapod安装 - 管理第三方库
在我们开发移动应用的时候,一般都会使用到第三方工具,而由于第三方类库的种类繁多,我们在项目中进行管理也会相对麻烦,所以此时我们就需要一个包管理工具,在iOS开发中,我们使用最多的就是Cocoapods ...
- python的random函数
Python中的random模块用于生成随机数.下面介绍一下random模块中最常用的几个函数. random.random random.random()用于生成一个0到1的随机符点数: 0 < ...
- Android 观察系统中短信内容的变化(内容观察者)
//内容观察者(如果系统的短信发生了变化,比如刚获取一条短信,那么将触发onChange方法) ContentResolver contentResolver = getContentResolver ...
- Android Mediaplayer各种属性和方法简单介绍
主要涉及类:MediaPlayer (1) 当一个MediaPlayer对象被创建或者调用reset()方法之后,它处于空闲状态,调用release()方法后处于结束状态 1,一个MediaPlaye ...
- PLSQL Developer Debug
如果要查看存储过程或者函数的执行过程,可以用debug的模式.PLSQL Developer提供了debug功能,以函数为例: 1. 找到你要debug的函数,然后右击—>选择“Add debu ...
- POJ_3616_Milking_Time_(动态规划)
描述 http://poj.org/problem?id=3616 给奶牛挤奶,共m次可以挤,给出每次开始挤奶的时间st,结束挤奶的时间ed,还有挤奶的量ef,每次挤完奶要休息r时间,问最大挤奶量. ...
- JSONP跨域的原理解析(转)
JavaScript是一种在Web开发中经常使用的前端动态脚本技术.在JavaScript中,有一个很重要的安全性限制,被称为"Same-Origin Policy"(同源策略). ...
- 作品第一课----改变DIV样式属性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- AudioMixer的脚本控制
AudioMixer是Unity5新特性之一,能很好的实现立体声效果. 这儿先记录一下脚本控制的方法: 1.添加一个Group,然后点击它 2.右侧面板上出现2个参数:pitch(速度)和volume ...