|
Hi, the problem is the next:
I have a view with a composite id:
<?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"> <hibernate-mapping package="es.ocaso.neg.giso.beans.proveedores"> <class name="Regional" table="TGVESTRU_1ESTRUCTU"> <composite-id name="idRegional" class="RegionalPK"> <key-property name="codigoCompania" column="COD_CIA_PK" type="char_trim" /> <key-property name="codigoOficinaHija" column="COD_OFI_HJ" type="char_trim" /> </composite-id> <property name="codigoOficinaPadre" column="COD_OFI_PD" type="char_trim" /> <property name="nivel" column="IND_NIVEL" /> <property name="descNombrePadre" column="DES_NOMBR_PD" type="char_trim" /> <property name="codigoClasePadre" column="COD_CLASE_PD" type="char_trim" /> <property name="nombrePadre" column="NOM_NOMBR_PD" type="char_trim" />
</class> </hibernate-mapping>
and I want to join it with a table. The two fields in the table that I want it to use like keys with the view are not the primary key of the table.
Here is the mapping table:
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="es.ocaso.neg.giso.beans.proveedores">
<class name="Delegacion" table="GSTDELEG" dynamic-insert="true" >
<composite-id name="id" class="DelegacionPK" > <key-property name="id" column="DELEG_COD_DELEG_PK" type="long" /> <key-property name="companya" column="COMPA_COD_COMPA_PK" type="char_trim" /> </composite-id> <many-to-one name="datosPersonales" column="DATPE_COD_DELEG" class="DatosPersonalesDelegacion" unique="true" not-null="true" cascade="save-update" lazy="false" /> <many-to-one name="direccion" column="DIREC_COD_DIREC_PK" class="DireccionDelegacion" unique="true" not-null="true" cascade="save-update" />
<many-to-one name="datosGerente" column="DATPE_COD_GERDELEG" class="DatosPersonalesGerenteDelegacion" cascade="save-update" unique="true" /> <property name="rol" column="ROLES_COD_ROL_PK" type="char_trim" length="3" /> <property name="pais" column="PAISE_COD_PAIS_PK" type="char_trim" length="2"/> <property name="medioComunicacion" column="MEDIO_COD_MEDIO_PK" type="char_trim" length="3" not-null="true"/> <property name="oficinaReferencia" column="DELEG_COD_OFICI_RE" type="char_trim" length="4" /> </class> </hibernate-mapping>
Fields:
codigoCompania (COD_CIA_PK) Field of the view
companya (COMPA_COD_COMPA_PK) Field of the table
codigoOficinaHija (COD_OFI_HJ) Field of the view
oficinaReferencia (DELEG_COD_OFICI_RE) Field of the table
The only thing I want to do it is mapp this two elements! Many-to-one, one-to-one..... whatever! It´s impossible!
I try everything, but doesn´t works! I put this on the table file and the load of hibernate is correct but doesn´t make the join:
<many-to-one name="regional" class="Regional" fetch="join" insert="false" update="false" property-ref="idRegional" > <column name="COMPA_COD_COMPA_PK" /> <column name="DELEG_COD_OFICI_RE" /> </many-to-one>
If some one have any idea to resolve this, please help me because I was 5 days to try to make this works.
Thank you
|