1、在学习hibernate的一对多多对一关系的时候,出现了一下错误:

2、错误原因:

这是因为在配置student.hbm.xml的配置文件的时候出现了将两个属性映射到同一个字段:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="pers.zhb.domain">
<class name="Student" table="student">
<id name="studentno" column="studentno" >
<generator class="native"></generator>
</id>
<property name="birthday" column="birthday"></property>
<property name="classno" column="classno" ></property>
<property name="email" column="email"></property>
<property name="phone" column="phone"></property>
<property name="sex" column="sex"></property>
<property name="sname" column="sname"></property>
<property name="point" column="point"></property>
<many-to-one name="aClas" column="classno" class="Clas"></many-to-one>
</class>
</hibernate-mapping>

3、解决方案:

 <property name="birthday" column="birthday"></property>
<property name="classno" column="classno" insert="false" update="false"></property>
<property name="email" column="email"></property>
<property name="phone" column="phone"></property>
<property name="sex" column="sex"></property>
<property name="sname" column="sname"></property>
<property name="point" column="point"></property>
<many-to-one name="aClas" column="classno" class="Clas"></many-to-one>

在属性的映射配置的地方加入insert="false" update="false"语句。

错误解决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中的"Repeated column in mapping for entity"异常

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

  2. SSH框架-Caused by: org.hibernate.MappingException: column attribute may not be used together with <column> subelement

    昨晚修改了一些表关系,在相关的hbm.xml文件中做了改动,今天早上起来启动tomcat后,发现项目启动不了,控制台报错: 2015-6-14 9:09:42 org.apache.catalina. ...

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

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

  4. org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/domain/book.hbm.xml 联网跑一跑

    org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/domain/boo ...

  5. 由异常: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=&quo ...

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

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

  8. Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource Caused by: org.hibernate.DuplicateMappingException: duplicate import: Person refers to both cn.itcast.

    此错误是说有两个相同的名字的配置文件,所以不知道查找哪个.解决方法就是把不需要的那个配置文件删除. 删除mapping中不需要的那个xml文件即可

  9. 错误解决:SharePoint Designer 2010编辑后,出现数据源控件未能执行插入命令,data source control failed to execute the insert command

    打了SharePoint 2010 最新的SP 2的补丁,但是使用SharePoint Designer 2010 定义任何一个列表的“插入视图”时,总是出现标题那样的错误: 数据源控件未能执行插入命 ...

随机推荐

  1. scratch教程:学做控制类积木

    少儿编程中scratch很容易被小孩所接受,不管是从外观还是教程中,都符合少儿的兴趣,为此现在只要是开少儿编程课都会有scratch课程,今天娜娜姐小码王scratch培训机构就为大家分享,scrat ...

  2. 阿里云服务器连接ftp服务(软件的使用)

    首先你需要有一个阿里云的ECS服务器 开通了宽带之后,ECS服务器就可以上网了 可以在本地电脑cmd控制台运行mstsc.exe启动远程桌面连接 windows+R 计算机名输入ECS服务器的公网ip ...

  3. c#创建windows服务(代码方式安装、启动、停止、卸载服务)

    转载于:https://www.cnblogs.com/mq0036/p/7875864.html 一.开发环境 操作系统:Windows 10 X64 开发环境:VS2015 编程语言:C# .NE ...

  4. ELK部署配置使用记录

    为什么要用ELK: 一般我们需要进行日志分析场景:直接在日志文件中 grep.awk 就可以获得自己想要的信息.但在规模较大的场景中,此方法效率低下,面临问题包括日志量太大如何归档.文本搜索太慢怎么办 ...

  5. Python删除列表元素的3种方法

    之前看教程的时候比较着急,对这些基础掌握不好,过来回顾一下 使用del语句删除 lis = [1, 2, 3, 'a', 'b'] print(lis) del lis[0] print(lis) 输 ...

  6. Map接口---Day20

    Map接口概述: 现实生活中,我们常会看到这样的一种集合:IP地址与主机名,身份证号与个人,系统用户名与系统用户对象等, 这种一一对应的关系,就叫做映射.Java提供了专门的集合类用来存放这种对象关系 ...

  7. Java自学-接口与继承 内部类

    Java 内部类 内部类分为四种: 非静态内部类 静态内部类 匿名类 本地类 步骤 1 : 非静态内部类 非静态内部类 BattleScore "战斗成绩" 非静态内部类可以直接在 ...

  8. YUV与RGB互转各种公式 (YUV与RGB的转换公式有很多种,请注意区别!!!)

    一. 公式:基于BT.601-6 BT601 UV 的坐标图(量化后): (横坐标为u,纵坐标为v,左下角为原点) 通过坐标图我们可以看到UV并不会包含整个坐标系,而是呈一个旋转了一定角度的八边形, ...

  9. spark源码阅读--shuffle过程分析

    ShuffleManager(一) 本篇,我们来看一下spark内核中另一个重要的模块,Shuffle管理器ShuffleManager.shuffle可以说是分布式计算中最重要的一个概念了,数据的j ...

  10. pandas-19 DataFrame读取写入文件的方法

    pandas-19 DataFrame读取写入文件的方法 DataFrame有非常丰富的IO方法,比如DataFrame读写csv文件excel文件等等,操作很简单.下面在代码中标记出来一些常用的读写 ...