Hi list,
Actually, I try to use all of the basics features of Castor JDO.
I have recently encountered a problem with the many-to-many relation :
- When I want to add an object existing (Class Sector) to an other object
(Class Actor) and create thw object Actor, the insert is done in the
Database (table actores) but the association table doesn't take care.
The Mapping Descriptor "mapping2.xml"
<!-- CLASE ACTOR-->
<class name="objetos.fundacite.Actor"
identity="cod_actor" key-generator="IDENTITY">
<description>Fundacite-Actor</description>
<map-to table="actores" xml="Actor" />
<field name="cod_actor" type="integer" >
<sql name="cod_actor" type="integer" />
<xml node="attribute"/>
</field>
<field name="ced_rif" type="string">
<sql name="ced_rif" type="char" dirty="check" />
<xml node="text" />
</field>
<field name="nombre_actor" type="string">
<sql name="nombre_actor" type="char" dirty="check" />
<xml node="text" />
</field>
<field name="tipo_actor" type="string">
<sql name="tipo_actor" type="char" dirty="ignore" />
<xml node="text" />
</field>
<field name="tipo_persona_legal" type="string">
<sql name="tipo_per_leg" type="char" dirty="check" />
<xml node="text" />
</field>
<field name="amb_estatal" type="integer">
<sql name="amb_estatal" type="integer"/>
<xml node="attribute" />
</field>
<field name="amb_nacional" type="integer">
<sql name="amb_nacional" type="integer" dirty="check" />
<xml node="attribute" />
</field>
<field name="amb_internacional" type="integer">
<sql name="amb_inter" type="integer"/>
<xml node="attribute" />
</field>
<field name="direccion" type="string">
<sql name="direccion" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="ciudad" type="string">
<sql name="ciudad" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="estado" type="string">
<sql name="estado" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="municipio" type="string">
<sql name="municipio" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="cod_postal" type="string">
<sql name="cod_postal" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="pais" type="string">
<sql name="pais" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="telefono" type="string">
<sql name="telefono" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="fax" type="string">
<sql name="fax" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="e_mail" type="string">
<sql name="e_mail" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="url" type="string">
<sql name="url" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="siglas" type="string">
<sql name="siglas" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="nat_jur" type="string">
<sql name="nat_jur" type="char" dirty="check"/>
<xml node="text" />
</field>
<field name="proyectos" type="objetos.fundacite.Proyecto_Fundacite"
required="true"
collection="vector">
<sql name="cod_proy"
many-table="proy_act" many-key="cod_actor" />
<xml name="Proyecto_Fundacite" node="element" />
</field>
<field name="sectores" type="objetos.fundacite.Sector" required="true"
collection="vector">
<sql name="cod_sec"
many-table="act_sect" many-key="cod_actor" />
<xml name="Sector" node="element" />
</field>
<field name="usuarios" type="objetos.fundacite.Usuario" required="true"
collection="vector">
<sql many-key="cod_actor" />
<xml name="Usuario" node="element" />
</field>
<field name="responsables" type="objetos.fundacite.Responsable"
required="true"
collection="vector">
<sql many-key="cod_actor" />
<xml name="Responsable" node="element" />
</field>
<field name="info_actor" type="objetos.fundacite.Informacion_Actor" >
<sql many-key="cod_actor" />
<xml name="Informacion_Actor" node="element" />
</field>
</class>
<!-- CLASE SECTOR -->
<class name="objetos.fundacite.Sector"
identity="cod_sec" key-generator="IDENTITY">
<description>Sector</description>
<map-to table="sector" xml="Sector" />
<field name="cod_sec" type="integer" >
<sql name="cod_sec" type="integer"/>
<xml node="attribute"/>
</field>
<field name="actores" type="objetos.fundacite.Actor" require="true"
collection="vector">
<sql many-table="act_sect" many-key="cod_sec" name="cod_actor"/>
<xml name="Actor" node="element" />
</field>
<field name="sector" type="string">
<sql name="sector" type="char" dirty="check" />
<xml node="text" />
</field>
<field name="proyectos" type="objetos.fundacite.Proyecto_Fundacite"
required="true"
collection="vector">
<sql many-table="proy_sect" many-key="cod_sec"
name="cod_proy"/>
<xml name="Proyecto_Fundacite" node="element" />
</field>
<field name="analistas" type="objetos.fundacite.Analista"
required="true"
collection="vector">
<sql name="cod_analista"
many-table="analista_sect" many-key="cod_sec" />
<xml name="Analista" node="element" />
</field>
</class>
test file
public static void main(String [] args) {
objetos.fundacite.Sector sectorRef= new objetos.fundacite.Sector();
objetos.fundacite.Actor actor = new Actor();
objetos.fundacite.Usuario usuario = new Usuario();
objetos.fundacite.Informacion_Actor info_actor = new Informacion_Acto();
Procesos p = new Procesos();
p.setMappingFile("mapping2.xml");
p.setDatabase("identificacion");
p.setDatabaseFile("database.xml");
p.setConexion("conectar");
sectorRef.setSector("Francis");
p.setSector(sectorRef);
actor.setNombre_actor("Gregoria");
actor.setTipo_actor("D");
info_actor.setServicios("Ayuda");
actor. setInfo_actor(info_actor);
usuario.setLogin("gregoria");
usuario.setPassword("123");
usuario.setTipo_login("actor");
usuario.setPermiso("2");
actor.addUsuarios(usuario);
actor.addSectores(sectorRef);
p.setActor(actor);
}
_________________________________________________________________
Charle con sus amigos online usando MSN Messenger: http://messenger.msn.com
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev