* @param col The column
* @return The column statement text
*/
public String referenceDatastoreField(DatastoreField col)
{
DatastoreContainerObject t = col.getDatastoreContainerObject();
String alias = null;
if (t.equals(mainTable))
{
alias = "THIS";
}
else
{
if (alias == null)
{
// Check if we have an inner join to this table
Iterator iter = innerTableMappings.entrySet().iterator();
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
InnerJoinDefinition join = (InnerJoinDefinition)entry.getValue();
if (t.equals(join.getTable()))
{
alias = (String)entry.getKey();
break;
}
}
}
}
if (alias == null)
{
// No join present so create INNER join
alias = "INNER" + (innerTableMappings.size()+1);
innerTableMappings.put(alias, new InnerJoinDefinition(t, t.getIDMapping()));
}
return col.applySelectFunction(alias + '.' + col.getIdentifier().toString());
}