Hi Isomorphic,
as the docs don't mention it, I wanted to know if this use of DataSourceField.foreignKey is officially supported.
I have a T_ADDRESS table, storing addresses for many different entities (users, resellers, leads, ...). Every row in that table has one and only one of the FKs set (via DB-CHECK-constraint). In each column (e.g. T_ADDRESS.RESELLER_ID), the values are unique (via DB-UNIQUE-constraint).
The T_ADDRESS.ds.xml looks like this:
Another ds.xml (T_RESELLER.ds.xml) is this:
T_LEAD_ONLYRESELLER.ds.xml is this:
Now if I assign a fetch to T_LEAD_ONLYRESELLER, following table clause is generated:
As you can see, the joins are generated correctly also backwards correctly - even over a middle T_RESELLER table. If this (which is GREAT) is intended, it would be good to include it in the docs.
I also noted that I have to have the includeVia="RESELLER_ID" in the last table (T_LEAD_ONLYRESELLER),
as there are two ways possible (the arrows being FKs)
and the framework chooses the T_LEAD-way if I omit it.
I also noted that relatedTableAlias="adr_res" (in T_ADDRESS) is not watched when generating the joins backwards.
Best regards and thumbs up once again for the really impressive framework,
Blama
as the docs don't mention it, I wanted to know if this use of DataSourceField.foreignKey is officially supported.
I have a T_ADDRESS table, storing addresses for many different entities (users, resellers, leads, ...). Every row in that table has one and only one of the FKs set (via DB-CHECK-constraint). In each column (e.g. T_ADDRESS.RESELLER_ID), the values are unique (via DB-UNIQUE-constraint).
The T_ADDRESS.ds.xml looks like this:
Code:
<DataSource dbName="Oracle" tableName="T_ADDRESS" ID="T_ADDRESS" serverType="sql">
<fields>
<field primaryKey="true" hidden="true" name="ID" type="sequence" />
.....
<field foreignKey="T_RESELLER.ID" name="RESELLER_ID" type="integer" joinType="outer" relatedTableAlias="adr_res"/>
<field foreignKey="T_LEAD.ID" name="LEAD_ID" type="integer" joinType="outer" />
<field name="STREET" length="50" type="text" escapeHTML="true" required="true" />
.....
</fields>
</DataSource>Another ds.xml (T_RESELLER.ds.xml) is this:
Code:
<DataSource dbName="Oracle" tableName="T_RESELLER" ID="T_RESELLER" serverType="sql">
<fields>
<field primaryKey="true" hidden="true" name="ID" type="sequence" foreignKey="V_CURRENT_ACCOUNT_COUNT.RESELLER_ID" joinType="outer" />
.....
<field name="NAME" title="Resellername" length="60" type="text" escapeHTML="true" required="true">
<validators>
<validator type="isUnique"></validator>
</validators>
</field>
</fields>
</DataSource>Code:
<DataSource dbName="Oracle" tableName="T_LEAD_ONLYRESELLER" ID="T_LEAD_ONLYRESELLER" serverType="sql">
<fields>
<field primaryKey="true" hidden="true" name="ID" type="sequence" />
<field hidden="true" name="TENANT_ID" type="integer" canEdit="false" />
<field foreignKey="T_LEAD.ID" name="LEAD_ID" title="LEAD_ID" type="integer" />
<field foreignKey="T_RESELLER.ID" name="RESELLER_ID" title="Reseller" type="integer" displayField="RESELLER_NAME" />
<field name="RESELLER_NAME" includeFrom="T_RESELLER.NAME" hidden="true" />
<field name="RESELLER_ZIPCODE" includeFrom="T_ADDRESS.ZIPCODE" includeVia="RESELLER_ID" />
<field name="RESELLER_CITY" includeFrom="T_ADDRESS.CITY" includeVia="RESELLER_ID" />
<!-- TENANT_IDs for WHERE-clause generation -->
<field name="CREATED_BY_TENANT_ID" includeFrom="V_USER_CREATED_BY.TENANT_ID" hidden="true" />
<field name="MODIFIED_BY_TENANT_ID" includeFrom="V_USER_MODIFIED_BY.TENANT_ID" hidden="true" />
<field name="RESELLER_TENANT_ID" includeFrom="T_RESELLER.TENANT_ID" hidden="true" />
<field name="ADDRESS_TENANT_ID" includeFrom="T_ADDRESS.TENANT_ID" includeVia="RESELLER_ID" hidden="true" />
</fields>
</DataSource>Code:
FROM t_lead_onlyreseller
JOIN t_reseller ON t_lead_onlyreseller.reseller_id = t_reseller.id
LEFT OUTER JOIN t_address a1 ON t_reseller.id = a1.reseller_id
JOIN v_user_created_by ON t_lead_onlyreseller.created_by = v_user_created_by.id
JOIN v_user_modified_by ON t_lead_onlyreseller.modified_by = v_user_modified_by.idI also noted that I have to have the includeVia="RESELLER_ID" in the last table (T_LEAD_ONLYRESELLER),
as there are two ways possible (the arrows being FKs)
Code:
T_LEAD_ONLYRESELLER -> T_LEAD <- T_ADDRESS
T_LEAD_ONLYRESELLER -> T_RESELLER <- T_ADDRESSI also noted that relatedTableAlias="adr_res" (in T_ADDRESS) is not watched when generating the joins backwards.
Best regards and thumbs up once again for the really impressive framework,
Blama