Discussion:
[Middlegen-user] many2many doesn't work
Peter Hulst
2004-11-04 20:17:46 UTC
Permalink
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
Eivind Waaler
2004-11-05 07:05:08 UTC
Permalink
Think this could be a problem with case:

<jointable name="REGIONS_HAS_COUNTRIES" generate="false"/>

CREATE TABLE REGIONS_has_COUNTRIES (

Try changing the jointable definition to use the same case as the table
name:

<jointable name="REGIONS_has_COUNTRIES" generate="false"/>

.eivind
Post by Peter Hulst
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
<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
-------------------------------------------------------
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
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Peter Hulst
2004-11-05 16:52:00 UTC
Permalink
thanks for your response, but that didn't make a difference.
Any other thoughts? Could it be an issue with my MySQL version or driver?

thanks
Peter
Post by Peter Hulst
<jointable name="REGIONS_HAS_COUNTRIES" generate="false"/>
CREATE TABLE REGIONS_has_COUNTRIES (
Try changing the jointable definition to use the same case as the table
<jointable name="REGIONS_has_COUNTRIES" generate="false"/>
.eivind
Post by Peter Hulst
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
<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
-------------------------------------------------------
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
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
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
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Loading...