| 
					
						 Hey, does anyone knows why does GlassFish throws this exception:
 org.hibernate.MappingException: Foreign key (FK4FDEDAA91B86637C:area_laboral [id_org_ubicacion])) must have same number of columns as the referenced primary key (organizacion_ubicacion [id_org_ubicacion,id_organizacion,id_pais,id_plaza])
 
 Here are my mapping documents:
 //////////////////OrganizacionUbicacion////////////////////////////////////////
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 <!-- Generated 27/02/2009 09:01:32 PM by Hibernate Tools 3.2.1.GA -->
 <hibernate-mapping>
     <class name="Pojos.OrganizacionUbicacion" table="organizacion_ubicacion" catalog="privilegios">
         <composite-id name="id" class="Pojos.OrganizacionUbicacionId">
             <key-property name="idOrgUbicacion" type="long">
                 <column name="id_org_ubicacion" />
             </key-property>
             <key-property name="idOrganizacion" type="long">
                 <column name="id_organizacion" />
             </key-property>
             <key-property name="idPais" type="long">
                 <column name="id_pais" />
             </key-property>
             <key-property name="idPlaza" type="string">
                 <column name="id_plaza" length="5" />
             </key-property>
         </composite-id>
         <many-to-one name="pais" class="Pojos.Pais" update="false" insert="false" fetch="select">
             <column name="id_pais" not-null="true" />
         </many-to-one>
         <many-to-one name="organizacion" class="Pojos.Organizacion" update="false" insert="false" fetch="select">
             <column name="id_organizacion" not-null="true" />
         </many-to-one>
         <many-to-one name="plaza" class="Pojos.Plaza" update="false" insert="false" fetch="select">
             <column name="id_plaza" length="5" not-null="true" />
         </many-to-one>
         <set name="areaLaborals" inverse="true">
             <key>
                 <column name="id_org_ubicacion" not-null="true" />
             </key>
             <one-to-many class="Pojos.AreaLaboral" />
         </set>
     </class>
 </hibernate-mapping>
 //////////////////////////////Organizacion////////////////////////////////////////
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 <!-- Generated 27/02/2009 09:01:32 PM by Hibernate Tools 3.2.1.GA -->
 <hibernate-mapping>
     <class name="Pojos.Organizacion" table="organizacion" catalog="privilegios">
         <id name="idOrganizacion" type="long">
             <column name="id_organizacion" />
             <generator class="assigned" />
         </id>
         <property name="nombreCorto" type="string">
             <column name="nombre_corto" length="25" />
         </property>
         <property name="nombreLargo" type="string">
             <column name="nombre_largo" length="150" not-null="true" />
         </property>
         <property name="altaStamp" type="timestamp">
             <column name="alta_stamp" length="19" not-null="true" />
         </property>
         <property name="modificaStamp" type="timestamp">
             <column name="modifica_stamp" length="19" />
         </property>
         <property name="bajaStamp" type="timestamp">
             <column name="baja_stamp" length="19" />
         </property>
         <property name="calleNumero" type="string">
             <column name="calle_numero" length="100" not-null="true" />
         </property>
         <property name="colonia" type="string">
             <column name="colonia" length="100" not-null="true" />
         </property>
         <property name="municipio" type="string">
             <column name="municipio" length="100" />
         </property>
         <property name="cp" type="string">
             <column name="cp" length="10" not-null="true" />
         </property>
         <property name="telefono" type="string">
             <column name="telefono" length="15" not-null="true" />
         </property>
         <set name="organizacionUbicacions" inverse="true">
             <key>
                 <column name="id_organizacion" not-null="true" />
             </key>
             <one-to-many class="Pojos.OrganizacionUbicacion" />
         </set>
     </class>
 </hibernate-mapping>
 //////////////////////////////Plaza////////////////////////////////////////
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 <!-- Generated 27/02/2009 09:01:32 PM by Hibernate Tools 3.2.1.GA -->
 <hibernate-mapping>
     <class name="Pojos.Plaza" table="plaza" catalog="privilegios">
         <id name="idPlaza" type="string">
             <column name="id_plaza" length="5" />
             <generator class="assigned" />
         </id>
         <property name="plaza" type="string">
             <column name="plaza" length="45" not-null="true" />
         </property>
         <property name="altaStamp" type="timestamp">
             <column name="alta_stamp" length="19" not-null="true" />
         </property>
         <property name="modificaStamp" type="timestamp">
             <column name="modifica_stamp" length="19" />
         </property>
         <property name="bajaStamp" type="timestamp">
             <column name="baja_stamp" length="19" />
         </property>
         <set name="plazaHorarios" inverse="true">
             <key>
                 <column name="id_plaza" length="5" not-null="true" unique="true" />
             </key>
             <one-to-many class="Pojos.PlazaHorario" />
         </set>
         <set name="organizacionUbicacions" inverse="true">
             <key>
                 <column name="id_plaza" length="5" not-null="true" />
             </key>
             <one-to-many class="Pojos.OrganizacionUbicacion" />
         </set>
     </class>
 </hibernate-mapping>
 /////////////////////////////////////////////////////////////////////////////////////
 And here is mysql queries for creating the tables:
 
 //////////////////////////////////Organizacion////////////////////////////////////
 CREATE TABLE  `privilegios`.`organizacion` (
   `id_organizacion` bigint(20) unsigned NOT NULL,
   `nombre_corto` varchar(25) default NULL,
   `nombre_largo` varchar(150) NOT NULL,
   `alta_stamp` datetime NOT NULL,
   `modifica_stamp` datetime default NULL,
   `baja_stamp` datetime default NULL,
   `calle_numero` varchar(100) NOT NULL,
   `colonia` varchar(100) NOT NULL,
   `municipio` varchar(100) default NULL,
   `cp` varchar(10) NOT NULL,
   `telefono` varchar(15) NOT NULL,
   PRIMARY KEY  (`id_organizacion`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 //////////////////////////////////OrganizacionUbicacion/////////////////////////
 CREATE TABLE  `privilegios`.`organizacion_ubicacion` (
   `id_org_ubicacion` bigint(20) unsigned NOT NULL,
   `id_organizacion` bigint(20) unsigned NOT NULL,
   `id_pais` bigint(20) unsigned NOT NULL,
   `id_plaza` char(5) NOT NULL,
   PRIMARY KEY  (`id_org_ubicacion`,`id_organizacion`,`id_pais`,`id_plaza`),
   KEY `FK_organizacion_ubicacion_1` (`id_organizacion`),
   KEY `FK_organizacion_ubicacion_2` (`id_pais`),
   KEY `FK_organizacion_ubicacion_3` (`id_plaza`),
   CONSTRAINT `FK_organizacion_ubicacion_1` FOREIGN KEY (`id_organizacion`) REFERENCES `organizacion` (`id_organizacion`),
   CONSTRAINT `FK_organizacion_ubicacion_2` FOREIGN KEY (`id_pais`) REFERENCES `pais` (`id_pais`),
   CONSTRAINT `FK_organizacion_ubicacion_3` FOREIGN KEY (`id_plaza`) REFERENCES `plaza` (`id_plaza`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 ///////////////////////////////////////Plaza////////////////////////////////////////
 CREATE TABLE  `privilegios`.`plaza` (
   `id_plaza` char(5) NOT NULL,
   `plaza` varchar(45) NOT NULL,
   `alta_stamp` datetime NOT NULL,
   `modifica_stamp` datetime default NULL,
   `baja_stamp` datetime default NULL,
   PRIMARY KEY  (`id_plaza`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 /////////////////////////////////////////////////////////////////////////////////////
 By the way; I used netbeans reverse enginering for generating the hbm files.
 So, does anyone knows where is the problem?? 
					
  
						
					 |