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.  [ 2 posts ] 
Author Message
 Post subject: Mapping with composite-id, impossible
PostPosted: Tue Jul 22, 2008 3:15 am 
Newbie

Joined: Mon Jul 21, 2008 9:43 am
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 8:10 am 
Newbie

Joined: Thu Jul 26, 2007 8:25 am
Posts: 6
try this one.........


<many-to-one name="regional" class="Regional" fetch="join" insert="false" update="false" >
<column name="codigoOficinaHija" />
<column name="oficinaReferencia" />
</many-to-one>


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

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.