-->
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 question
PostPosted: Mon Jul 17, 2006 10:45 am 
Newbie

Joined: Tue Jan 31, 2006 5:22 pm
Posts: 6
Location: Argentina
Hi!!

i have a problem mapping 3 tables and need help.
Tables:

Code:
create table Aumentos ( aumentos_id int not null primary key, ....... )
create table Aumentos_Detalle ( aumentos_id int not null, mod_sec_cc_id int not null, mod_sec_especialidad_id int not null, primary key (aumentos_id, mod_sec_cc_id, mod_sec_especialidad_id) )
create table Aumentos_Valor ( aumentos_id int not null, mod_sec_cc_id int not null, mod_sec_especialidad_id int not null, mod_sec_plan_id int not null, primary key (aumentos_id, mod_sec_cc_id, mod_sec_especialidad_id, mod_sec_plan_id) )


Classes:
Aumento / AumentoDetalle / AumentoValor

Code:
public class Aumento extends ... implements ... {
   ....
   /** <AumentoDetalle> */
   private Set detalles = new HashSet();
   ....
}

Code:
public class AumentoDetalle extends ... implements ... {
   ....
   private SecundariaModalidad modalidadCentroCosto = null;
   private SecundariaModalidad modalidadEspecialidad = null;

   /** <AumentoValor> */
   private Set valores = new HashSet();
   ....
}

Code:
public class AumentoValor extends ... implements ... {
   ....
   private SecundariaModalidad modalidadCentroCosto = null;
   private SecundariaModalidad modalidadEspecialidad = null;
   private SecundariaModalidad modalidadPlan = null;
}


My doubts are:
Aumento and AumentoDetalle must have bidirectional associations ? if not, how could hibernate realize that in order
to insert a record in 'Aumentos_Valor' it needs Aumento's id in 'AumentoDetalle' ?
AumentoDetalle and AumentoValor should have bidirectional associations?

Thanks in advance,

Nicolas Gonzalez

P.S.: Sorry for my english!!
Code:
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 17, 2006 11:28 am 
Newbie

Joined: Tue Jul 11, 2006 5:14 am
Posts: 10
Location: Paris, France
Hola,
No siempre hay necesidad de declarar todas las relaciones, pero las que si que no puedes dejar de lado es declarar al padre y si lo he entendido bien Aumento es el abuelo que tiene un set de AumentoDetalle(padre) y este a su vez tiene un set de AumentoValor (nietos), en este caso quien has de declarar es AumentoDetalle en AumentoValor y en la tabla cambiarlo tambien para mantener esta escalera. sino lo que tienes es un padre y 2hermanos hijos con lo que
Code:
/** <AumentoValor> */
   private Set valores = new HashSet();

debiera estar directamente en el padre Aumento

Yo creo que una vez este esto claro si debe ser bidireccional o no ya se vara, paero ahora mismo la estructura de las clases y las tablas es contradictoria

Suerte


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.