Hibernate version: 3.0
Hello everyone,
I'm having problems writing a part of a mapping. First of all, I have these mappings:
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="auge.bean.MpProducao" table="MPPRODUCAO" >
<composite-id>
<key-many-to-one name="materia" column="materia" class="auge.bean.MateriaPrima"
lazy="false"/>
<key-property name="numeroOrdemItens" column="numeroOrdemItens" type="java.lang.Integer"/>
</composite-id>
<property name="quantidade" column="quantidade" type="java.lang.Float" />
<property name="baixaDada" column="baixaDada" type="java.lang.Integer" />
<many-to-one name="cor" column="cor" class="auge.bean.Cor"
not-null="false" lazy="false"/>
</class>
</hibernate-mapping>
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="auge.bean.OrdemItens" table="ORDEMITENS" >
<id name="numeroOrdemItens" column="numeroOrdemItens" type="java.lang.Integer">
<generator class="assigned"/>
</id>
<property name="tamanho" column="tamanho" type="java.lang.String" />
<property name="qtdePedida" column="qtdePedida" type="java.lang.Integer" />
<property name="qtdeFabricar" column="qtdeFabricar" type="java.lang.Integer" />
<property name="processoAtivo" column="processoAtivo" type="java.lang.Integer" />
<many-to-one name="ordemDeProducao" column="numeroOrdem" class="auge.bean.OrdemDeProducao"
not-null="false" lazy="false"/>
<many-to-one name="produto" column="produto" class="auge.bean.Produto"
not-null="false" lazy="false"/>
<many-to-one name="cor" column="cor" class="auge.bean.Cor"
not-null="false" lazy="false"/>
</class>
</hibernate-mapping>
I'm trying to put into the second mapping (auge.bean.OrdemItens) a set of the first one. I've tried it this way:
Code:
<set name="mpProducao" inverse="true" cascade="all" >
<key>
<column name="numeroOrdemItens"></column>
<column name="materia"></column>
</key>
<one-to-many class="auge.bean.MpProducao" />
</set>
But I get an error saying:
Foreign key (FKC24B75B6576D388F:MPPRODUCAO [numeroOrdemItens,materia])) must have same number of columns as the referenced primary key (ORDEMITENS [numeroOrdemItens])
What's wrong? Thanks for the help