Brian Cochran
2002-09-17 22:39:01 UTC
Hey All,
When I specify many2many relationships the one2many relationships to the
mapping table are still generated and although no entity is generated, the
references to it are. For example:
A *- C -* B representing a many2many between A and B. I am using the
following
<table name="A" generate="true" />
<table name="B" generate="true" />
<many2many>
<tablea name="A" generate="true" />
<jointable name="C" generate="false" />
<tableb name="B" generate="true" />
</many2many>
I create the database with
CREATE TABLE A ( aId integer, ..., PRIMARY KEY(aId));
CREATE TABLE B ( bId integer, ..., PRIMARY KEY(bId));
CREATE TALBE C ( aId, bId, PRIMARY KEY(aId,bId),
FOREIGN KEY(aId) REFERENCES A,
FOREIGN KEY(bId) REFERENCES B );
Middlegen will not create the entity C but it will not remove the
one-to-many relation from C to A or vise-versa if the relationship is
bidirectional. What I am wondering is why, after you have found the
existance of a many2many, are the one2manys kept around. This has been
causing me problems because the relationship between (A,B) and (C) is still
generated but the entity C does not exist.
I'm looking at the last line of addMany2ManyRelationships and wondering if
we couldn't add something in there to remove the one2many we just replaced.
Let me know if I'm just missing something here.
Thanks a bunch,
Brian
When I specify many2many relationships the one2many relationships to the
mapping table are still generated and although no entity is generated, the
references to it are. For example:
A *- C -* B representing a many2many between A and B. I am using the
following
<table name="A" generate="true" />
<table name="B" generate="true" />
<many2many>
<tablea name="A" generate="true" />
<jointable name="C" generate="false" />
<tableb name="B" generate="true" />
</many2many>
I create the database with
CREATE TABLE A ( aId integer, ..., PRIMARY KEY(aId));
CREATE TABLE B ( bId integer, ..., PRIMARY KEY(bId));
CREATE TALBE C ( aId, bId, PRIMARY KEY(aId,bId),
FOREIGN KEY(aId) REFERENCES A,
FOREIGN KEY(bId) REFERENCES B );
Middlegen will not create the entity C but it will not remove the
one-to-many relation from C to A or vise-versa if the relationship is
bidirectional. What I am wondering is why, after you have found the
existance of a many2many, are the one2manys kept around. This has been
causing me problems because the relationship between (A,B) and (C) is still
generated but the entity C does not exist.
I'm looking at the last line of addMany2ManyRelationships and wondering if
we couldn't add something in there to remove the one2many we just replaced.
Let me know if I'm just missing something here.
Thanks a bunch,
Brian