我有一个休眠映射文件 ParcelServicePresetIds.hbm.xml:
<hibernate-mapping>
<class name="de.delife.sql.ParcelServicePresetIds" table="ParcelServicePresetIDs" schema="dbo" catalog="xxx">
<id name="id" type="int">
<column name="ID" />
<generator class="assigned" />
</id>
<many-to-one name="itemsBase" class="de.sql.ItemsBase" fetch="select" property-ref="itemId">
<column name="ItemID" />
</many-to-one>
<property name="itemId" column="ItemID" type="java.lang.Integer"/>
<property name="intValue" type="java.lang.Integer">
<column name="intValue" />
</property>
</class>
</hibernate-mapping>
当我运行我的程序时,我得到一个错误:
Initial SessionFactory creation failed.org.hibernate.MappingException: Repeated column in mapping for entity: de.sql.ParcelServicePresetIds column: ItemID (should be mapped with insert="false" update="false")
为什么?
我有另一个实体 Others.hbm.xml:
<many-to-one name="itemsBase" class="de.sql.ItemsBase" fetch="select" property-ref="itemId">
<column name="ItemID" unique="true" />
</many-to-one>
<property name="itemId" column="ItemID" type="java.lang.Integer"/>
在这个实体中它正在工作!!!我不明白!有人可以解释其中的区别吗?