Discussion:
[Middlegen-user] Need foreign key column for one side of a one-to-many relation
Rod Macpherson
2002-11-20 14:23:05 UTC
Permalink
The table interface allows me to iterate over foreign keys and relations
for that table. I need to know the one-side column name of a one-to-many
relation while iterating over the one-side RelationshipRole objects of a
given table. That information does not appear to be available. The
getManyRelationshipRole method is returning many side roles but what I
am interested in is the one-side roles associated with the table. I
added getOneRelationshipRoles using the predicate that was provided out
of the box. That worked fine but one-side roles have no column
information. I would like to know the name of the foreign key associated
with that role. Here's a velocity snippet that encapsulates the issue:

#if( !$table.oneRelationshipRoles.empty )
#foreach( $role in $table.oneRelationshipRoles )
[print the name of the foreign key]
Rod Macpherson
2002-11-21 03:07:01 UTC
Permalink
Problem Solved

I am fetching the foreign key column name I was looking for using the RelationshipRole returned by getRelationshipRoles in the TableDecorator: I filter out roles using isTargetMany to get the one-side information that I was looking for. The following strategy did not work because for some reason the ColumnMap information was not available:

getRelationshipRoles(middlegen.predicates.relation.TargetOne.getInstance());



-----Original Message-----
From: Rod Macpherson
Sent: Wed 11/20/2002 8:23 AM
To: middlegen-***@lists.sourceforge.net
Cc:
Subject: [Middlegen-user] Need foreign key column for one side of a one-to-many relation


The table interface allows me to iterate over foreign keys and relations for that table. I need to know the one-side column name of a one-to-many relation while iterating over the one-side RelationshipRole objects of a given table. That information does not appear to be available. The getManyRelationshipRole method is returning many side roles but what I am interested in is the one-side roles associated with the table. I added getOneRelationshipRoles using the predicate that was provided out of the box. That worked fine but one-side roles have no column information. I would like to know the name of the foreign key associated with that role. Here's a velocity snippet that encapsulates the issue:

#if( !$table.oneRelationshipRoles.empty )
#foreach( $role in $table.oneRelationshipRoles )
[print the name of the foreign key]

Loading...