-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: org.hibernate.MappingException
PostPosted: Fri Aug 14, 2009 4:14 pm 
Newbie

Joined: Fri Aug 14, 2009 3:43 pm
Posts: 1
Hi everyone im developing an enterprise (erp+bpm) system, so this is my problem:

im trying to represent an inheritance between these two table

Quote:
MdiDocumentocDTO

Quote:
Documento


the first one (the child) has a composite
Quote:
codempresa, coddocumento
id and the second which is the (the father) has a natural key
Quote:
numero
here is the mapping code:

Code:
<?xml version="1.0"?>
<!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 - Hibernate Tools
-->
<hibernate-mapping>

       <-- CLASS JBPM DOCUMENT WORKFLOW -->

   <class name="com.obelisco.modelo.data.contenido.Documento" table="documento"
      schema="public" lazy="false">

      <id name="numero" type="java.lang.Long">
         <column name="numero" />
         <generator class="sequence">
            <param name="sequence">documento_numero_seq</param>
         </generator>
      </id>

      <many-to-one name="directorio"
         class="com.obelisco.modelo.data.contenido.Directorio" fetch="select">
         <column name="directorio" />
      </many-to-one>

      <many-to-one name="tipodocumento"
         class="com.obelisco.modelo.data.contenido.TipoDocumento" fetch="select">
         <column name="tipodocumento" length="3" />
      </many-to-one>

      <many-to-one name="padre"
         class="com.obelisco.modelo.data.contenido.Documento" fetch="select">
         <column name="documentodepende" />
      </many-to-one>

      <many-to-one name="propietario"
         class="com.obelisco.modelo.data.seguridad.Usuario" fetch="select">
         <column name="propietario" length="14" />
      </many-to-one>

      <property name="creacion" type="java.util.Date">
         <column name="creacion" length="4" not-null="true" />
      </property>

      <property name="ultimaactualizacion" type="java.util.Date">
         <column name="ultimaactualizacion" length="4" not-null="true" />
      </property>

      <many-to-one name="processInstance" class="org.jbpm.graph.exe.ProcessInstance"
         fetch="select" cascade="none">
         <column name="processinstance" />
      </many-to-one>

      <property name="activo" column="activo" />

      <set name="hijos" inverse="true" cascade="all" lazy="true">
         <key>
            <column name="documentodepende" />
         </key>
         <one-to-many class="com.obelisco.modelo.data.contenido.Documento" />
      </set>

      <set name="asociados" table="asociado" cascade="persist" lazy="true"
         schema="public">
         <key>
            <column name="documento" length="10" not-null="true" />
         </key>
         <many-to-many column="relacionado"
            class="com.obelisco.modelo.data.contenido.Documento" />
      </set>



      <set name="recursos" inverse="true" cascade="all-delete-orphan"
         lazy="true">
         <key>
            <column name="documento" />
         </key>
         <one-to-many class="com.obelisco.modelo.data.contenido.Recurso" />
      </set>
      
      <!--Mapping for initial documents-->
      
      <joined-subclass name="com.sigesp.modelo.dto.mdi.MdiDocumentocDTO" table="mdidocumentoc" schema="public">
        <comment>Modulo Documentos Iniciales - Documentos Iniciales - Tabla tipo Cabecera Tabla que contiene los registros de Documentos Iniciales</comment>

      <key>
      <column name="codempresa" ></column>
      <column name="coddocumento"></column>
      </key>

        <property name="codtipdocumento" type="java.lang.String">
            <column name="codtipdocumento" length="2" />
        </property>
        <property name="codrelacion" type="java.lang.Integer">
            <column name="codrelacion" precision="5" scale="0" />
        </property>
        <property name="tipdestdocumento" type="java.lang.String">
            <column name="tipdestdocumento" length="1" />
        </property>
        <property name="codproveedor" type="java.lang.Integer">
            <column name="codproveedor" precision="8" scale="0" />
        </property>
        <property name="codmemo" type="java.lang.String">
            <column name="codmemo" length="2" />
        </property>
        <property name="cedpassbeneficiario" type="java.lang.String">
            <column name="cedpassbeneficiario" length="15" />
        </property>
        <property name="coduniejecutora" type="java.lang.Integer">
            <column name="coduniejecutora" precision="6" scale="0" />
        </property>
        <property name="codfuefinanciamiento" type="java.lang.Short">
            <column name="codfuefinanciamiento" precision="3" scale="0" />
        </property>
        <property name="descdocumento" type="java.lang.String">
            <column name="descdocumento" />
        </property>
        <property name="estdocumento" type="java.lang.String">
            <column name="estdocumento" length="1" />
        </property>
        <property name="estado" type="java.lang.String">
            <column name="estado" length="1" />
        </property>
        <property name="fecregdocumento" type="java.util.Date">
            <column name="fecregdocumento" length="13" />
        </property>
        <property name="fecaprdocumento" type="java.util.Date">
            <column name="fecaprdocumento" length="13" />
        </property>
        <property name="fecanudocumento" type="java.util.Date">
            <column name="fecanudocumento" length="13" />
        </property>
        <property name="feccondocumento" type="java.util.Date">
            <column name="feccondocumento" length="13" />
        </property>
      
      </joined-subclass>

   </class>


</hibernate-mapping>


The Exception:

Code:
Unable to start servlet container.org.mortbay.util.MultiException[org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Compass' defined in file [E:\Desarrollos\Sigesp\REPOSITORIO_14_07_08\WS_MyEclipse_Sigesp\WORKSPACE1\sigesp.integracion\out\WEB-INF\classes\applicationContext-base.xml]: Cannot resolve reference to bean 'TransactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TransactionManager' defined in file [E:\Desarrollos\Sigesp\REPOSITORIO_14_07_08\WS_MyEclipse_Sigesp\WORKSPACE1\sigesp.integracion\out\WEB-INF\classes\applicationContext-base.xml]: Cannot resolve reference to bean 'SessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SessionFactory' defined in file [E:\Desarrollos\Sigesp\REPOSITORIO_14_07_08\WS_MyEclipse_Sigesp\WORKSPACE1\sigesp.integracion\out\WEB-INF\classes\applicationContext-conexion.xml]: Invocation of init method failed; nested exception is [b]org.hibernate.MappingException: Foreign key (FK7068B36165509A9F:mdidocumentoc [codempresa,coddocumento])) must have same number of columns as the referenced primary key (documento [numero])][/b]



i've heard that i cant use a composite id in a joined subclass. The exception thrown tells me that the number of column of both table are not the same... but i need to know if there is a way to make it ? i could change my model to natural key but this surrogate key is pretty relevant as this system is multi enterprise... very apretiate if you have a answer for me.

regards...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.