我面临着hibernate中类映射的问题。我试着用合成身份证来建立一对一的关系。地图又回来了
实体映射中的重复列: br.com.is.isenterprise.cre.model.ClienteRegraIcmsMap列: EMPRESAID (应该使用insert="false“update=”false“映射)
但是,如果将多对一关系设置为insert =" false "和update =" false,则无法在数据库中插入regraIcmsSubistituta的id。跟踪hbm文件。
RegraIcms.hbm.xml
<hibernate-mapping package="br.com.is.isenterprise.efi.model">
<class name="RegraIcms" table="REGRAICMS">
<composite-id name="cid" class="br.com.is.isenterprise.efi.model.RegraIcmsId">
<key-property name="empCod" type="integer" column="EMPCOD"/>
<key-property name="idRegraIcms" type="integer" column="IDREGRAICMS"/>
</composite-id>
<property name="descricao" type="string" column="DESCRICAO" access="field"/>
<property name="aplicacao" type="integer" column="APLICACAO" access="field"/>
</class>
</hibernate-mapping>ClienteRegraIcmsMapId.hbm.xml
<class name="ClienteRegraIcmsMap" table="CLIENTEREGRAICMSMAP">
<composite-id name="cid" class="br.com.is.isenterprise.cre.model.ClienteRegraIcmsMapId">
<key-many-to-one name="cliente" column="CLIENTEID" class="br.com.is.isenterprise.cre.model.Cliente" access="field" lazy="false"/>
<key-many-to-one name="regraIcms" class="br.com.is.isenterprise.efi.model.RegraIcms" access="field" lazy="false">
<column name="EMPRESAID"/>
<column name="REGRAICMSID"/>
</key-many-to-one>
</composite-id>
<version name="versao" type="integer" column="VERSAO"/>
<many-to-one name="regraIcmsSubstituta" class="br.com.is.isenterprise.efi.model.RegraIcms" access="field" lazy="false">
<column name="EMPRESAID"/>
<column name="REGRAICMSSUBSTITUTAID"/>
</many-to-one>
</class>
</hibernate-mapping>发布于 2017-09-20 14:29:24
您试图将同一列(EMPRESAID)用于两种不同的内容,即主键和多对一关系。
这是行不通的(除了插入= "false",正如您提到的那样)
如果可能的话,在其中一个映射中为EMPRESAID使用单独的列。
https://stackoverflow.com/questions/46322070
复制相似问题