zoukankan      html  css  js  c++  java
  • 错误解决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 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"语句。

  • 相关阅读:
    cors解决跨域
    神经网络和keras
    tensorflow笔记
    5.聚类算法-kmeans
    4.回归类算法-目标值连续型
    3.分类算法-目标值离散型
    Phaser.js开发小游戏之洋葱头摘星星
    VS Code 插件之 vscode-debug-visualizer
    Phaser.js开发小游戏之Phaser.js介绍
    微信小程序中写threejs系列之 threejs-miniprogram
  • 原文地址:https://www.cnblogs.com/zhai1997/p/11861103.html
Copyright © 2011-2022 走看看