由异常: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 ...
随机推荐
- JDBC导致的反序列化攻击
背景 上周BlackHat Europe 2019的议题<New Exploit Technique In Java Deserialization Attack>中提到了一个通过注入JD ...
- Vue ---- vue的基本使用 文本/事件/属性指令 补充: js面向对象 js函数
目录 日考题(知识点)
- LeetCode529. 扫雷游戏 Python3 DFS+BFS+注释
https://leetcode-cn.com/problems/minesweeper/solution/python3-dfsbfszhu-shi-by-xxd630/ 规则: 'M' 代表一个未 ...
- LeetCode刷题总结-二分查找和贪心法篇
本文介绍LeetCode上有关二分查找和贪心法的算法题,推荐刷题总数为16道.具体考点归纳如下: 一.二分查找 1.数学问题 题号:29. 两数相除,难度中等 题号:668. 乘法表中第k小的数,难度 ...
- Internet History,Technology,and Security - History: Commercialization and Growth(Week4)
Explosive Growth of the Internet and Web The Year of the Web 正如你所知道的,1994年是网络之年.1994年,NCSA的一位员工离职并建立 ...
- Springboot vue.js html 跨域 前后分离 shiro权限 集成代码生成器
本代码为 Springboot vue.js 前后分离 + 跨域 版本 (权限控制到菜单和按钮) 后台框架:springboot2.1.2+ mybaits+maven+接口 前端页面:html + ...
- MySQL MHA /usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln301] install_driver(mysql) failed: Attempt to reload DBD/mysql.pm aborted
在公司随便找3台测试机搭个MHA,下面这个问题折腾了三天,之前没遇到过,查了OS版本发现一致,可能是不同人弄的OS吧,知道是cpan的问题就是搞不定,郁闷...[root@test247 ~]# ma ...
- 单片机内核Cortex-M3八大知识点
单片机内核Cortex-M3的八个知识点 1.指令集 32位ARM指令集:对应ARM状态 16位Thumb指令集:对应Thumb状态(是ARM指令集的一个子集) 指令集演进图 2.BKP备份寄存 ...
- ubuntu下安装tomcat,shutdown时报错:./catalina.sh:1:eval:/home/xxx/jdk/jre/bin/java:not found
该问题可能导致tomcat启动成功了,但是浏览器输入http://127.0.0.1:8080无法显示tomcat的欢迎界面 打开Tomcat安装目录下的bin文件下的setclasspath.sh, ...
- 避免 C# TreeView NodeMouseDoubleClick 双击事件的节点错位的错误行为
避免 C# TreeView NodeMouseDoubleClick 双击事件的节点错位的错误行为 在使用WinForm标准的TreeView控件的过程中,添加了如下类似的节点 parentNode ...