由异常: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关联的思考的更多相关文章

  1. 玩转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: ...

  2. 玩转JPA(一)---异常:Repeated column in mapping for entity/should be mapped with insert=&quot;false&quot; update=&quot;fal

    近期用JPA遇到这样一个问题:Repeated column in mapping for entity: com.ketayao.security.entity.main.User column: ...

  3. Hibernate中的"Repeated column in mapping for entity"异常

    转:http://lijiejava.iteye.com/blog/786535 一对多双向关联(类Item与类Bid): Item类: public class Item { private int ...

  4. Java EE之Hibernate异常总结org.hibernate.MappingException: Repeated column in mapping for entity:

    解决方案/原因: 一个pojo(JavaBean)中不能有两个属性同时映射到一个数据库字段上 即使是一个属性的两个getter方法也不行 %%%% Error Creating SessionFact ...

  5. 错误解决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 ...

  6. 使用EF访问数据库,出现“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常。

    今天在使用的EF时候,发生了"System.Data.Entity.Internal.AppConfig"的类型初始值设定项引发异常.这样的一个错误 查了原因,原来是appconf ...

  7. System.Data.Entity.Internal.AppConfig"的类型初始值设定项引发异常

    在学习EF code First的小案例的时候,遇见了这个异常 <configSections> <!-- For more information on Entity Framew ...

  8. Entity Framework: Get mapped table name from an entity

    The extension methods I have created one extension method for DbContext and other for ObjectContext: ...

  9. 错误/异常:org.hibernate.MappingException: Unknown entity: com.shore.entity.Student 的解决方法

    1.错误/异常视图 错误/异常描述:Hibernate配置文件 映射异常,不明实体类Student(org.hibernate.MappingException: Unknown entity: co ...

随机推荐

  1. Java中final修饰的数据

    目录 Java中final修饰的数据 有初始值的final域 final+基本数据类型 final+引用数据类型 final与static final 空白final域 final修饰的参数 基本数据 ...

  2. 如何使用Jmeter进行压力测试

    Jmeter做压力测试的操作:Jmeter不仅可以做接口测试,还可以做压力测试,下面介绍介绍如何jmeter进行简单地压力测试.具体步骤如下: 第一步:添加请求,这里不介绍具体步骤,详见(https: ...

  3. 细解JavaScript ES7 ES8 ES9 新特性

    题记:本文提供了一个在线PPT版本,方便您浏览 细解JAVASCRIPT ES7 ES8 ES9 新特性 在线PPT ver 本文的大部分内容译自作者Axel Rauschmayer博士的网站,想了解 ...

  4. Ubuntu 18.04 美化配置

    网上很多关于Ubuntu 18.04 美化的配置,但每个人遇见的问题都有些不太一样, 现将本人配置的过程整理如下 更新源为阿里云 找到Software & Updates,将源更新为阿里云的源 ...

  5. android 7.0+、8.0+应用中点击拍照崩溃的解决办法

    在开发中,项目里面明明已经添加过拍照或者读取相册的权限,但是在点击拍照或者打开相册的时候应用会崩溃,报一下错误: Caused by: android.os.FileUriExposedExcepti ...

  6. Tomcat系列(一)- 整体架构

    整体架构 我们想要了解一个框架,首先要了解它是干什么的,Tomcat我们都知道,是用于处理连接过来的Socket请求的.那么Tomcat就会有两个功能: 对外处理连接,将收到的字节流转化为自己想要的R ...

  7. Python 分支、循环、条件与枚举

    单行注释:# 注释内容多行注释:''' 注释内容 '''   Python 中有三种控制流语句: if for while 注:Python 中没有 Switch 这种开关语句 if 语句检测条件真, ...

  8. SpringBoot微服务电商项目开发实战 --- Kafka集成接入

    kafka作为消息中间件的一款产品,她比较轻量级,在吞吐量方面很优秀,默认消息持久化到硬盘当中 168小时=7天,log.retention.hours=168,比较适合来做运营的统计.其他的不多讲, ...

  9. 入职小白随笔之Android四大组件——活动详解(activity)

    推荐Android入门书籍:第一行代码(郭霖) google官方文档地址:https://developer.android.google.cn/guide/components/activities ...

  10. JDK1.8新特性-Lambda表达式

    Lambda 表达式 Lambda 表达式,也可称为闭包,它是推动 Java 8 发布的最重要新特性. Lambda 允许把函数作为一个方法的参数(函数作为参数传递进方法中). 使用 Lambda 表 ...