Title: RE: [Middlegen-user] Getting Foreign Key from RelationshipRole
The problem is not in fact not whether I am using a predicate or testing for targetMany. I will try that again but let me go back to my original question by way of example. I will leave out the velocity script and simply pose the question: 
 
I have a MASTER table and  three foreign key columns that are one-to-many. I want to iterate over the relations for the MASTER table and display the foreign key column name associated with each child set.

I hope this is clear and I apologize for the mix-up with the getManyRelationshipRoles which was really a side issue.  

 

-----Original Message-----
From: Rod Macpherson
Sent: Sun 12/8/2002 12:40 PM
To: Aslak Hellesøy; [EMAIL PROTECTED]
Cc:
Subject: RE: [Middlegen-user] Getting Foreign Key from RelationshipRole

Oops! I omitted a rather important detail. I added getManyRelationshipRoles so there is both a one and a many:
 
// This existed
public Collection getOneRelationshipRoles() {
    return getRelationshipRoles(middlegen.predicates.relation.TargetOne.getInstance());
 }
 
// This was added
public Collection getManyRelationshipRoles() {
    return getRelationshipRoles(middlegen.predicates.relation.TargetMany.getInstance());
 }
When iterating of the filtered result there is no column map on the "target" role. Iterating over all of them and then testing for "many" works fine but should these not be equivalent?
 
(P.S. getting this email through outlook web access and do not see a plain text setting)
 
-----Original Message-----
From: Aslak Hellesøy [mailto:[EMAIL PROTECTED]]
Sent: Sun 12/8/2002 11:05 AM
To: Rod Macpherson; [EMAIL PROTECTED]
Cc:
Subject: RE: [Middlegen-user] Getting Foreign Key from RelationshipRole

TableDecorator doesn't have a getManyRelationshipRoles() method, so it's the first loop you'll never enter. Try:

#foreach($role in $table.relationshipRoles)
  #if($role.targetMany)
    #foreach( $map in $role.columnMaps )
        System.out.println("${map.foreignKey}"); 
    #end
  #end
#end

Aslak

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Rod Macpherson
Sent: 8. desember 2002 19:37
To: [EMAIL PROTECTED]
Subject: [Middlegen-user] Getting Foreign Key from RelationshipRole


I am iterating over a set of one-to-many relationship roles for a given table in my velocity script.  When the target is "many" the columnMaps array is always empty. How would I print out the foreign key columns in this case? This snippet provides no output because the map is always empty. Where does that information reside?

#foreach($role in $table.manyRelationshipRoles)
    #foreach( $map in $role.targetRole.columnMaps )
        System.out.println("${map.foreignKey}"); 
    #end
#end

All ideas welcome!

Reply via email to