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. MATBLAB学习笔记----基础绘图

    整理自台大生机系郭彦甫.MATLAB系列教程,吐血推荐看这个视频,非计算机专业也能看懂,全程干货 MATLAB图形来自于“数据”,MATLAB不能理解函数. MATLAB绘图原理: 1.在特定范围生成 ...

  2. 删除排序链表中的重复元素II --链表

    题目 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现 的数字. 示例1 输入: ->->->->->-> 输出: ->-> ...

  3. CentOS7 firewalld防火墙 启动 关闭 禁用 添加删除规则等 常用命令

    CentOS7 firewalld防火墙 常用命令1.firewalld的基本使用启动: systemctl start firewalld关闭: systemctl stop firewalld查看 ...

  4. SUSE12Sp3-安装DockerCE和Docker-compose

    最近在写脚本.发现还是很方便的. Docker下载地址:https://download.docker.com/linux/static/stable/x86_64/ 执行以下脚本即可安装完毕. #! ...

  5. java jsp文件报错解决方法

    初次使用java开发 下载好代码之后,用maven编译都是ok的,第二天,打开项目一看,好的web项目的jsp文件提示错误,后面,查了下问题,是tomcat没有配置路径导致的问题,现在大致记录一下解决 ...

  6. AppTheme属性设置集合

    现在新建一个项目基本都会在 style.xml 设置基础的 AppTheme,但是系统的给提供的设置属性又比较多. 所以在此收集记录,以便之后查找方便. <style name="Ap ...

  7. 使用Nexus3搭建Maven私服+上传第三方jar包到本地maven仓库

    1.搭建Maven私服背景 公司还是按捺不住,要搭建一个自己的Maven本地仓库,可以让开发人员down架包,从内网还是快很多. 这样公司的maven本地仓库就是 开发人员自己电脑上的maven仓库 ...

  8. 把EXECL表格导入到WORD中

    一般我们在编写开发文档时需要进行表格导入导出,这里提供几种方法供参考. 法一: 打开EXECL,WORD软件,在需要导入表格的地方选择“插入” ,找到“对象选项: ”在对象对话框中点击“由文件创建”, ...

  9. Java 数组(一)定义与访问

    一.数组 1.容器概述    容器:是将多个数据存储到一起,每个数据称为该容器的元素. 2.数组概述  数组:数组就是存储数据长度固定的容器,保证多个数据的数据类型要一致. 数组特点: (1)数组是一 ...

  10. linux下执行python 提示module找不到 要加入系统路劲才找得到

    linux/cmd中python路径导入ModuleNotFoundError: No module named 'xxx'   import osimport syscurPath = os.pat ...