日期:2014-05-17  浏览次数:20695 次

一对多关系中,多的一方即是主键又是外键,myeclipse逆向工程生成hbm.xml文件问题
本帖最后由 u014490157 于 2014-04-01 17:09:26 编辑
多的一方plasmids hbm.xml配置文件
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.wsw.model.Plasmids" table="PLASMIDS" schema="PUBLIC" catalog="PUBLIC">
        <id name="entriesId" type="long">
            <column name="ENTRIES_ID" />
            <generator class="assigned" />
        </id>
        <many-to-one name="entries" class="com.wsw.model.Entries"  cascade="save-update" fetch="select">
           <column name="ENTRIES_ID" not-null="true" unique="true"/>
        </many-to-one>
        <property name="backbone" type="string">
            <column name="BACKBONE" length="127" />
        </property>
        <property name="circular" type="boolean">
            <column name="CIRCULAR" />
        </property>
        <property name="originOfReplication" type="string">
            <column name="ORIGIN_OF_REPLICATION" length="127" />
        </property>
        <property name="promoters" type="string">
            <column name="PROMOTERS" length="512" />
        </property>
        <property name="replicatesIn" type="string">
            <column name="REPLICATES_IN" />
        </property>
    </class>
</hibernate-mapping>

注意最上面的两个column name,两个一样:Repeated column in mapping for entity
执行insert,update的时候:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Repeated column in mapping for entity: com.wsw.model.Plasmids co