由异常: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 ...
随机推荐
- 【Spring Boot】定时任务
[Spring Boot]定时任务 测试用业务Service package com.example.schedule.service; import org.springframework.ster ...
- 3年Java开发10面阿里、京东、拼多多
拼多多 地点:2号线娄山关路地铁站(金虹桥国际中心) 环境:新的写字楼,环境很好,有种高大上的感觉.大厅进入后需要登记,然后进闸机.电梯是需要刷卡才能使用的.会议室都是用城市名称命名,例如杭州.香港等 ...
- PostgreSQL 、springboot 、spring data jpa 集成
项目地址:https://gitee.com/zhxs_code/PostgreSQL_springboot_jpa_demo.git 增删查改都已经实现. 重点部分: 1.定义自己的方言. pack ...
- webpack打包出现WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' for this value. 错误
打包运行的时候出现以下错误 WARNING in configurationThe 'mode' option has not been set, webpack will fallback to ' ...
- Git详细教程之创建本地仓库和连接Github仓库
首先要知道不只有代码,任何类型的文件都可以进行版本控制,版本控制很重要的一个特性就是你可以随时修改,比如git会记录你的任何操作,如果你想要回退到任何一个历史操作,你可以通过git轻松达到. 本地仓库 ...
- python函数编程-偏函数partial function
一般的,通过设定函数参数的默认值,可以减低函数调用的难度.比如:int()函数可以把字符串转换成整数: >>> int(') 123 事实上,int()函数还提供额外的base参数, ...
- 这几天加班熬夜把所有Python库整理了一遍,非常全面!
库名称简介 Chardet 字符编码探测器,可以自动检测文本.网页.xml的编码.colorama 主要用来给文本添加各种颜色,并且非常简单易用.Prettytable 主要用于在终端或浏览器端构建格 ...
- 软件开发工具(第8章:Eclipse工作台)
一.初识Eclipse工作台 Eclipse 工作台(Workbench)是一个高级用户界面框架,它为用 户提供了一个整体结构和可扩展的用户界面. 什么是工作空间(记忆) 工作空间(Workspace ...
- 中移动物联手机端APP软件
https://open.iot.10086.cn/doc/book/device-develop/multpro/sdk-doc-tool/APP.html
- python爬虫学习心得:中国大学排名(附代码)
今天下午花时间学习了python爬虫的中国大学排名实例,颇有心得,于是在博客园与各位分享 首先直接搬代码: import requests from bs4 import BeautifulSoup ...