* Currently only ManyToMany and OneToOne may have relation table.
* The method is overridden to return null for other subclasses.
* The returned relationTable still could be null.
*/
public DatabaseTable getRelationTable(ClassDescriptor referenceDescriptor) {
ExpressionIterator expIterator = new ExpressionIterator() {
public void iterate(Expression each) {
if(each.isTableExpression()) {
((Collection)this.getResult()).add(((TableExpression)each).getTable());
}
else if(each.isDataExpression()) {
DatabaseField field = ((DataExpression)each).getField();
if(field != null && field.hasTableName()) {
((Collection)this.getResult()).add(field.getTable());
}
} else if(each.isParameterExpression()) {
DatabaseField field = ((ParameterExpression)each).getField();
if(field != null && field.hasTableName()) {
((Collection)this.getResult()).add(field.getTable());
}
}
}
};
expIterator.setResult(new HashSet());
expIterator.iterateOn(this.joinCriteria);
HashSet<DatabaseTable> tables = (HashSet)expIterator.getResult();
DatabaseTable relationTable = null;
Iterator<DatabaseTable> it = tables.iterator();
while(it.hasNext()) {
DatabaseTable table = it.next();