You can't actually refer to a created class by GUID in the transformation. It actually doesn't exist yet. However, if class N is being created from A or a relation to A then you can refer to it using the TRANSFORM_REFERENCE.
Now, I think I know what you're after. So I'll try a bit of an impromptu tutorial.
Problem description: The default DDL transform does not create an intersection table for many to many associations in the PIM. Without this, the generated model isn't much use to you.
Solution: Generate the appropriate intersection table out of any many to many assocations.
The default templates create a foreign key connector out of any associations. For n-m associations we also need to create another table.
%if connectorSourceMultiplicity!="" and connectorSourceMultiplicity!="0" and connectorSourceMultiplicity!="0..1" and connectorSourceMultiplicity!="1"%
$sourceMultiple="T"
%endIf%
%if connectorDestMultiplicity != "" and connectorDestMultiplicity != "0" and connectorDestMultiplicity != "0..1" and connectorDestMultiplicity != "1"%
$destMultiple="T"
%endIf%
%if $sourceMultiple=="T" and $destMultiple=="T"%
$joinKey=%connectorSourceElemName% + "_" + %connectorDestElemName% + "ID"
$joinKey=%CONVERT_NAME($joinKey, "Pascal Case","Camel Case")%
Table
{
%TRANSFORM_REFERENCE("JoinTable",connectorGUID)%
name=%qt%Join_%connectorSourceElemName%_%connectorDestElemName%%qt%
language=%qt%%genOptDefaultDatabase%%qt%
PrimaryKey
{
Column
{
name=%qt%$joinKey%qt%
type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"Integer")%%qt%
}
}
}
%endIf%
All this does is check for the multiplicity of either end and create the appropriate table. It doesn't create any associations to this table. The important thing to note is the TRANSFORM_REFERENCE. This is the unique ID that identifies this join table. We need to use this to link this table to any other table.
Have a look at how the ForeignKey template creates a link between two existing classes. In the source and target block it repeats the TRANSFORM_REFERENCE of the classes it is linking to.
So we'll need to know the references to three different tables.
$sourceTable=%TRANSFORM_REFERENCE("Table",connectorSourceElemGUID)%
$destTable=%TRANSFORM_REFERENCE("Table",connectorDestElemGUID)%
$joinTable=%TRANSFORM_REFERENCE("JoinTable",connectorGUID)%
If I now modify the ForeignKey template to directly use references given to it, rather than just the source guids. Then call this template as appropriate.
The following templates are the result, including copying the appropriate multiplicities to the new connectors.
Connector %if connectorType!="Association"%
%endTemplate%
$sourceTable=%TRANSFORM_REFERENCE("Table",connectorSourceElemGUID)%
$destTable=%TRANSFORM_REFERENCE("Table",connectorDestElemGUID)%
%if connectorSourceMultiplicity!="" and connectorSourceMultiplicity!="0" and connectorSourceMultiplicity!="0..1" and connectorSourceMultiplicity!="1"%
$sourceMultiple="T"
%endIf%
%if connectorDestMultiplicity != "" and connectorDestMultiplicity != "0" and connectorDestMultiplicity != "0..1" and connectorDestMultiplicity != "1"%
$destMultiple="T"
%endIf%
$fkdoubleguid=%connectorSourceElemGUID%+%connectorDestElemGUID%
%if $sourceMultiple=="T" and $destMultiple=="T"%
$joinTable=%TRANSFORM_REFERENCE("JoinTable",connectorGUID)%
$joinKey=%connectorSourceElemName% + "_" + %connectorDestElemName% + "ID"
$joinKey=%CONVERT_NAME($joinKey, "Pascal Case","Camel Case")%
Table
{
$joinTable
name=%qt%Join_%connectorSourceElemName%_%connectorDestElemName%%qt%
language=%qt%%genOptDefaultDatabase%%qt%
PrimaryKey
{
Column
{
name=%qt%$joinKey%qt%
type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"Integer")%%qt%
}
}
}
%ForeignKey(connectorGUID,$sourceTable,$joinTable,connectorDestElemName,connectorSourceElemGUID,connectorSourceMultiplicity,"1..1")%
%ForeignKey(connectorGUID,$destTable,$joinTable,connectorSourceElemName,connectorDestElemGUID,connectorDestMultiplicity,"1..1")%
%elseIf $destMultiple=="T"%
%ForeignKey(connectorGUID,$destTable,$sourceTable,connectorSourceElemName,$fkdoubleguid,connectorDestMultiplicity,connectorSourceMultiplicity)%
%else%
%ForeignKey(connectorGUID,$sourceTable,$destTable,connectorDestElemName,$fkdoubleguid,connectorSourceMultiplicity,connectorDestMultiplicity)%
%endIf%
ForeignKey $connectorGUID=$parameter1
$source=$parameter2
$dest=$parameter3
$destName=$parameter4
$referenceName=$parameter5
$sourceMult=$parameter6
$destMult=$parameter7
ForeignKey
%PI="\n "%
{
%TRANSFORM_REFERENCE($referenceName,$connectorGUID)%
Source
{
$source
multiplicity=%qt%$sourceMult%qt%
Column
{
name=%qt%%CONVERT_NAME($destName, "Pascal Case","Camel Case")%ID%qt%
type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"Integer")%%qt%
}
}
Target
{
$dest
multiplicity=%qt%$destMult%qt%
Column
{
name=%qt%%CONVERT_NAME($destName, "Pascal Case","Camel Case")%ID%qt%
type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"Integer")%%qt%
}
%PI="\n"%
}
}
Any questions?