// Construct the SELECT query
StringBuilder query = new StringBuilder();
query.append("SELECT COUNT(*) FROM ");
char prefix = 'A';
BaseTableDef base = (BaseTableDef) omdb.getDBDef();
while ( base != null ) {
// Get the components of the SELECT query
String tableStr = getProperName( base.getNameDef() );
query.append(tableStr).append( ' ' ).append( prefix );
if ( base instanceof TableDef ) {
TableDef table = (TableDef) base;
base = null;
InheritenceDef idef = table.getInheritence();
if ( idef != null ) {
base = idef.getRefTable();
prefix++;
query.append( " LEFT JOIN " );
tableStr = getProperName( base.getNameDef() );
query.append(tableStr).append( ' ' ).append( prefix );
query.append( " ON " );
query.append( prefix-- ).append( idef.getColumnName() )
.append( "=" ).append( prefix ).append( idef.getRefColumn().getName() );
}