Title: 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