many2many doesn't work

Peter Hulst <[email protected]> Thu, 04 Nov 2004 14:18:50 -0800
Newsgroups gmane.comp.java.ejb.middlegen.user
Message-ID <[email protected]>
I'm trying to declare a many2many relationship with Middlegen and the 
Hibernate plugin but for some reason it doesn't work.

I'm getting the message 'The many2many relation 
COUNTRIES-REGIONS_HAS_COUNTRIES-REGIONS was declared, but not identified. '
In the Middlegen gui, both tables show up but no relation is displayed. All 
other one-to-many and one-to-one relationships display just fine

I have a many-to-many relationship between countries and regions and the 
mapping in my build file looks like this:

<many2many>
   <tablea name="REGIONS"/>
   <jointable name="REGIONS_HAS_COUNTRIES" generate="false"/>
   <tableb name="COUNTRIES"/>
</many2many>

The regions_has_countries table is generated as follows (using dbdesigner4)


CREATE TABLE REGIONS_has_COUNTRIES (
   REGION_ID INTEGER UNSIGNED NOT NULL,
   COUNTRY_ID INTEGER UNSIGNED NOT NULL,
   PRIMARY KEY(REGION_ID, COUNTRY_ID),
   INDEX REGIONS_has_COUNTRIES_FKIndex1(REGION_ID),
   INDEX REGIONS_has_COUNTRIES_FKIndex2(COUNTRY_ID),
   FOREIGN KEY regions_countries_link(REGION_ID)
     REFERENCES REGIONS(REGION_ID)
       ON DELETE NO ACTION
       ON UPDATE NO ACTION,
   FOREIGN KEY countries_regions_link(COUNTRY_ID)
     REFERENCES COUNTRIES(COUNTRY_ID)
       ON DELETE NO ACTION
       ON UPDATE NO ACTION
)
TYPE=InnoDB;

so as far as I'm aware the foreign keys and indexes have been defined 
correctly.

I'm using MySQL 4.1.5-gamma-nt, JDBC driver 
mysql-connector-java-3.0.15-ga-bin.jar, middlegen 2.1


any help/suggestions appreciated,
thanks Peter






-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click