由异常:Repeated column in mapping for entity/should be mapped with insert="false" update="false 引发对jpa关联的思考
由异常:Repeated column in mapping for entity/should be mapped with insert="false" update="false 引发对jpa关联的思考
首先说一下以上问题的解决方法
//主键列 显示指定只读 --这块是解决该文的代码
@Column(name = "xxx", insertable = false, updatable = false)
@OneToMany(fetch = FetchType.LAZY)
//关联异常时忽略异常
@NotFound(action = NotFoundAction.IGNORE)
//关联,显性指定关联字段
@JoinColumns({@JoinColumn(name = "xxx", referencedColumnName = "xxx_ID", insertable = false, updatable = false) })
List<TargetPersonModel> xxxs;
对于该问题的思考
1:首先解读一下column中insert 和 update的作用
/**
* (Optional) Whether the column is included in SQL INSERT
* statements generated by the persistence provider.
*/
boolean insertable() default true;
是否这一列别包含在持久化插入sql中是可以选择的
/**
* (Optional) Whether the column is included in SQL UPDATE
* statements generated by the persistence provider.
*/
boolean updatable() default true;
是否这一列被包含在持久化更新sql中是可以选择的
2:这段代码对应的sql在数据库中无问题,但是代码关联确保这个错误
sql:普通的左连接,这里就不贴啦,
问题可能的原因:在关联过程中进行啦 插入或者更新操作
解答上面的问题:已经显示指定啦insertable 和 updateable在joincolumns中 为什么还么报错?还要在字段上指定insert和update?
针对该问题(已经显示指定啦insertable 和 updateable 为什么还么报错)回答:因为这俩个属性只是针对外键,即name字段,
针对该问题(还要在字段上指定insert和update?):而我在column中指定insert和update是在referencecolumnname上。
由异常:Repeated column in mapping for entity/should be mapped with insert="false" update="false 引发对jpa关联的思考的更多相关文章
- 玩转JPA(一)---异常:Repeated column in mapping for entity/should be mapped with insert="false" update="fal
最近用JPA遇到这样一个问题:Repeated column in mapping for entity: com.ketayao.security.entity.main.User column: ...
- 玩转JPA(一)---异常:Repeated column in mapping for entity/should be mapped with insert="false" update="fal
近期用JPA遇到这样一个问题:Repeated column in mapping for entity: com.ketayao.security.entity.main.User column: ...
- Hibernate中的"Repeated column in mapping for entity"异常
转:http://lijiejava.iteye.com/blog/786535 一对多双向关联(类Item与类Bid): Item类: public class Item { private int ...
- Java EE之Hibernate异常总结org.hibernate.MappingException: Repeated column in mapping for entity:
解决方案/原因: 一个pojo(JavaBean)中不能有两个属性同时映射到一个数据库字段上 即使是一个属性的两个getter方法也不行 %%%% Error Creating SessionFact ...
- 错误解决Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: pers.zhb.domain.Student column: classno (should be mapped with insert="false" update="false")
1.在学习hibernate的一对多多对一关系的时候,出现了一下错误: 2.错误原因: 这是因为在配置student.hbm.xml的配置文件的时候出现了将两个属性映射到同一个字段: <?xml ...
- 使用EF访问数据库,出现“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常。
今天在使用的EF时候,发生了"System.Data.Entity.Internal.AppConfig"的类型初始值设定项引发异常.这样的一个错误 查了原因,原来是appconf ...
- System.Data.Entity.Internal.AppConfig"的类型初始值设定项引发异常
在学习EF code First的小案例的时候,遇见了这个异常 <configSections> <!-- For more information on Entity Framew ...
- Entity Framework: Get mapped table name from an entity
The extension methods I have created one extension method for DbContext and other for ObjectContext: ...
- 错误/异常:org.hibernate.MappingException: Unknown entity: com.shore.entity.Student 的解决方法
1.错误/异常视图 错误/异常描述:Hibernate配置文件 映射异常,不明实体类Student(org.hibernate.MappingException: Unknown entity: co ...
随机推荐
- 回归损失函数2 : HUber loss,Log Cosh Loss,以及 Quantile Loss
均方误差(Mean Square Error,MSE)和平均绝对误差(Mean Absolute Error,MAE) 是回归中最常用的两个损失函数,但是其各有优缺点.为了避免MAE和MSE各自的优缺 ...
- [系列] Go 使用 defer 函数 要注意的几个点
概述 defer 函数大家肯定都用过,它在声明时不会立刻去执行,而是在函数 return 后去执行的. 它的主要应用场景有异常处理.记录日志.清理数据.释放资源 等等. 这篇文章不是分享 defer ...
- Linux下搭建HttpRunnerManager接口测试平台
前言 之前在学习HttpRunner时,我们都是把用例写在 YAML/JSON 中进行维护,使用起来也很方便.其实,现在有不少大佬都喜欢开发自动化测试平台,比如我们今天要搭建的HttpRunnerMa ...
- 02-EF Core笔记之保存数据
EF Core通过ChangeTracker跟踪需要写入数据库的更改,当需要保存数据时,调用DbContext的SaveChanges方法完成保存. 基本的添加.更新.删除操作示例如下: using ...
- PythonI/O进阶学习笔记_8.python的可迭代对象和迭代器、迭代设计模式
content: 1.什么是迭代协议 2. 什么是迭代器(Iterator)和可迭代对象(Iterable) 3. 使用迭代器和可迭代对象 4. 创建迭代器和可迭代对象 5. 迭代器设计模式 一 ...
- Idea集成及使用svn插件
1 idea集成svn 1.1 svn是什么? SVN是subversion的缩写,是一个开放源代码的版本控制系统,通过采用分支管理系统的高效管理,简而言之就是用于多个人共同开发同一个项目,实现共享资 ...
- Scrum Meeting - 第六周【Alpha阶段】
每日任务内容: 本次会议为第六次Scrum Meeting会议 本次会议项目经理召开时间为20:00,在北区男生宿舍楼召开,召开时长约15分钟,探讨了本周选课网站编写的后续工作. 小组成员 本周任务 ...
- FontLab VI for Mac 键盘快捷键
使用FontLab VI for Mac,您可以创建,打开,修改,绘制,空间,文字,提示和导出桌面,网页,颜色和可变字体.该应用程序是一个全能的字体编辑器,但也支持与其他字体创建工具的数据交换,使其易 ...
- HUE Oozie : error=2, No such file or directory采坑记录
HUE Oozie : error=2, No such file or directory采坑记录 1.错误详情 一直都是同一种方式在hue上定义workflow,不知为啥 今天定义的就是不行... ...
- 龙芯(mips64)电脑安装NodeJS
背景 龙芯是国产的cpu,采用是mips架构,就类似大家熟知的x86.arm. 最近在一台龙芯电脑(系统是中兴新支点,Linux)上调试前端应用(electron),于是就需要安装NodeJS. 但是 ...