由异常: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. Windows安装MSYS2_切换zsh_整合cmder

    MSYS2是什么 MSYS2 (Minimal SYStem 2) 是一个MSYS的独立改写版本,主要用于 shell 命令行开发环境.同时它也是一个在Cygwin (POSIX 兼容性层) 和 Mi ...

  2. harbor部署常见的错误

    总结部署harbor过程所遇到的一些坑   1:在使用docker push镜像的时候提示:denied: requested access to the resource is denied,用户和 ...

  3. 1篇文章搞清楚8种JVM内存溢出(OOM)的原因和解决方法

    前言 撸Java的同学,多多少少会碰到内存溢出(OOM)的场景,但造成OOM的原因却是多种多样. 堆溢出 这种场景最为常见,报错信息: java.lang.OutOfMemoryError: Java ...

  4. java8新特性- 默认方法 在接口中有具体的实现

    案例分析 在java8中在对list循环的时候,我们可以使用forEach这个方法对list进行遍历,具体代码如下demo所示 public static void main(String[] arg ...

  5. 简单学习【1】——使用webpack

    使用webpack webpack命令 webpack配置 第三方脚手架 1.webpack命令 webpack - h (webpack 所有的选项) webpack -v (查看webpack的版 ...

  6. django基础之day09,Forms组件在程序中做了哪些事? 校验数据、渲染标签、展示信息

    ******************************* Forms组件 *************************************************** Forms组件在 ...

  7. 咪咕音乐链接歌词封面搜索等接口API

    搜索 pd.musicapp.migu.cn/MIGUM2.0/v1.0/content/search_all.do?&ua=Android_migu&version=5.0.1&am ...

  8. Ghost手动备份、还原系统详细图文教程

    1.Ghost工具下载 https://pan.baidu.com/s/10cpRhhjJAHZb5PPZo6ghvw 2.备份.还原详细步骤请参考 https://jingyan.baidu.com ...

  9. Dynamics 365 Portal 修改注册页面及Profile页面

    一,Profile页面 客户要求在Portal Profile页面上添加性别字段,通过查看源代码发现,中间的联系人信息部分是引用的CRM中Contact实体的Portal Web Form表单,直接把 ...

  10. sqlserver update join 多关联更新

    由于程序bug,导致之前很多数据入库后信息不全,好在有基础信息表,可以通过基础信息表更新缺失字段信息 1.通过 inner join语法实现多关联更新 update a set a.name = b. ...