fullRuntime/src/sc/db/DBPropertyDescriptor.java
public void resetTable(TableDescriptor mainPropTable) {
      if (tableDesc != null) {
         if (tableDesc.reverseProperty == this)
            return; // this likely means we are in runtimeMode - we set this table up in the compiled definition
         if (tableDesc.reverseProperty != null)
            System.err.println("*** Reverse property conflict");
         if (tableDesc.primary) {
            TableDescriptor primaryTable = tableDesc;
            if (!primaryTable.columns.remove(this))
               System.err.println("*** Unable to find column to remove for resetTable");
            tableDesc = new TableDescriptor(mainPropTable.tableName);
            tableDesc.reference = true;
            tableDesc.dbTypeDesc = dbTypeDesc;
            if (!columnType.equals(reversePropDesc.columnType))
               System.err.println("*** Relationships and reverse don't have matching columnTypes");

            // The id property in this side's table is the value column in the reverse table
            IdPropertyDescriptor thisIdProp = new IdPropertyDescriptor(primaryTable.idColumns.get(0).propertyName, reversePropDesc.columnName, columnType, false, null);
            // The value column for this property is the reverse table's id column - TODO: deal with multi column primary keys by overriding this in MultiColPropertyDescriptor
            columnName = mainPropTable.idColumns.get(0).columnName;
            tableDesc.idColumns = Collections.singletonList(thisIdProp);
            tableDesc.columns = new ArrayList<DBPropertyDescriptor>();
            tableDesc.columns.add(this);
            if (isMultiRowProperty())
               dbTypeDesc.addMultiTable(tableDesc);
            else
               dbTypeDesc.addAuxTable(tableDesc);
         }
         else {
            tableDesc.tableName = mainPropTable.tableName;
            tableDesc.reference = true;
            if (tableDesc.multiRow) {
               if (mainPropTable.multiRow) {
                  // We are going to turn mainPropTable into a many-to-many table using mainProp's join name
                  tableDesc.idColumns.get(0).columnName = mainPropTable.columns.get(0).columnName;
                  mainPropTable.idColumns.get(0).columnName = tableDesc.columns.get(0).columnName;
               }
               // Create the table descriptor for the many side of a one-to-many case
               else {
                  tableDesc.reverseProperty = this;
                  tableDesc.idColumns.get(0).columnName = reversePropDesc.columnName;
                  // First select the reverse props id as part of the reference so we can create the instance
                  ArrayList<DBPropertyDescriptor> selectCols = new ArrayList<DBPropertyDescriptor>(mainPropTable.idColumns);
                  // Then select all of the properties in the default table for the reverse side of the reference
                  for (int i = 0; i < mainPropTable.columns.size(); i++) {
                     DBPropertyDescriptor mainProp = mainPropTable.columns.get(i);
                     if (mainProp == reversePropDesc)
                        continue;
                     selectCols.add(mainProp);
                  }
                  /*
                  if (dbTypeDesc.runtimeMode && tableDesc.columns != null) {
                     // In runtime model, the tables have already been set up with the right columns but we do need to initialize them here
                     if (false && selectCols.size() == tableDesc.columns.size()) {
                        for (DBPropertyDescriptor selectCol:tableDesc.columns)
                           selectCol.init(selectCol.dbTypeDesc, tableDesc);
                     }
                     else {
                        tableDesc.columns = selectCols;
                     }
                  }
                  else {
                  */
                     tableDesc.columns = selectCols;
                     for (DBPropertyDescriptor selectCol:selectCols)
                        selectCol.init(selectCol.dbTypeDesc, tableDesc);
                  //}
               }
            }
         }
      }
   }
/**
    * This is called when we determine that this property's value is derived from the table provided. If this table is
    * already an aux table, or one-to-many relationship, this property's table takes the name of the other table.
    * If it is a primary table for this type, need to create a new aux/multi table
    * If this is a many-to-many relationship, both tables get reconfigured to use the property names as the id columns
    * although each table uses the opposite column for the id
    */
This is called when we determine that this property's value is derived from the table provided. If this table is
already an aux table, or one-to-many relationship, this property's table takes the name of the other table.
If it is a primary table for this type, need to create a new aux/multi table
If this is a many-to-many relationship, both tables get reconfigured to use the property names as the id columns
although each table uses the opposite column for the id
This is called when we determine that this property ' s value is derived from the table provided . If this table is already an aux table or one - to - many relationship this property ' s table takes the name of the other table . If it is a primary table for this type need to create a new aux / multi table If this is a many - to - many relationship both tables get reconfigured to use the property names as the id columns although each table uses the opposite column for the id
public void resetTable(TableDescriptor mainPropTable) {
      if (tableDesc != null) {
         if (tableDesc.reverseProperty == this)
            return; 
         if (tableDesc.reverseProperty != null)
            System.err.println("*** Reverse property conflict");
         if (tableDesc.primary) {
            TableDescriptor primaryTable = tableDesc;
            if (!primaryTable.columns.remove(this))
               System.err.println("*** Unable to find column to remove for resetTable");
            tableDesc = new TableDescriptor(mainPropTable.tableName);
            tableDesc.reference = true;
            tableDesc.dbTypeDesc = dbTypeDesc;
            if (!columnType.equals(reversePropDesc.columnType))
               System.err.println("*** Relationships and reverse don't have matching columnTypes");
            IdPropertyDescriptor thisIdProp = new IdPropertyDescriptor(primaryTable.idColumns.get(0).propertyName, reversePropDesc.columnName, columnType, false, null);
            columnName = mainPropTable.idColumns.get(0).columnName;
            tableDesc.idColumns = Collections.singletonList(thisIdProp);
            tableDesc.columns = new ArrayList<DBPropertyDescriptor>();
            tableDesc.columns.add(this);
            if (isMultiRowProperty())
               dbTypeDesc.addMultiTable(tableDesc);
            else
               dbTypeDesc.addAuxTable(tableDesc);
         }
         else {
            tableDesc.tableName = mainPropTable.tableName;
            tableDesc.reference = true;
            if (tableDesc.multiRow) {
               if (mainPropTable.multiRow) {
                  tableDesc.idColumns.get(0).columnName = mainPropTable.columns.get(0).columnName;
                  mainPropTable.idColumns.get(0).columnName = tableDesc.columns.get(0).columnName;
               }
               else {
                  tableDesc.reverseProperty = this;
                  tableDesc.idColumns.get(0).columnName = reversePropDesc.columnName;
                  ArrayList<DBPropertyDescriptor> selectCols = new ArrayList<DBPropertyDescriptor>(mainPropTable.idColumns);
                  for (int i = 0; i < mainPropTable.columns.size(); i++) {
                     DBPropertyDescriptor mainProp = mainPropTable.columns.get(i);
                     if (mainProp == reversePropDesc)
                        continue;
                     selectCols.add(mainProp);
                  }
                  /*
                  if (dbTypeDesc.runtimeMode && tableDesc.columns != null) {
                     // In runtime model, the tables have already been set up with the right columns but we do need to initialize them here
                     if (false && selectCols.size() == tableDesc.columns.size()) {
                        for (DBPropertyDescriptor selectCol:tableDesc.columns)
                           selectCol.init(selectCol.dbTypeDesc, tableDesc);
                     }
                     else {
                        tableDesc.columns = selectCols;
                     }
                  }
                  else {
                  */
                     tableDesc.columns = selectCols;
                     for (DBPropertyDescriptor selectCol:selectCols)
                        selectCol.init(selectCol.dbTypeDesc, tableDesc);
               }
            }
         }
      }
   }
public void resetTable ( TableDescriptor mainPropTable ) { if ( tableDesc != null ) { if ( tableDesc . reverseProperty == this ) return ; if ( tableDesc . reverseProperty != null ) System . err . println ( "*** Reverse property conflict" ) ; if ( tableDesc . primary ) { TableDescriptor primaryTable = tableDesc ; if ( ! primaryTable . columns . remove ( this ) ) System . err . println ( "*** Unable to find column to remove for resetTable" ) ; tableDesc = new TableDescriptor ( mainPropTable . tableName ) ; tableDesc . reference = true ; tableDesc . dbTypeDesc = dbTypeDesc ; if ( ! columnType . equals ( reversePropDesc . columnType ) ) System . err . println ( "*** Relationships and reverse don't have matching columnTypes" ) ; IdPropertyDescriptor thisIdProp = new IdPropertyDescriptor ( primaryTable . idColumns . get ( 0 ) . propertyName , reversePropDesc . columnName , columnType , false , null ) ; columnName = mainPropTable . idColumns . get ( 0 ) . columnName ; tableDesc . idColumns = Collections . singletonList ( thisIdProp ) ; tableDesc . columns = new ArrayList < DBPropertyDescriptor > ( ) ; tableDesc . columns . add ( this ) ; if ( isMultiRowProperty ( ) ) dbTypeDesc . addMultiTable ( tableDesc ) ; else dbTypeDesc . addAuxTable ( tableDesc ) ; } else { tableDesc . tableName = mainPropTable . tableName ; tableDesc . reference = true ; if ( tableDesc . multiRow ) { if ( mainPropTable . multiRow ) { tableDesc . idColumns . get ( 0 ) . columnName = mainPropTable . columns . get ( 0 ) . columnName ; mainPropTable . idColumns . get ( 0 ) . columnName = tableDesc . columns . get ( 0 ) . columnName ; } else { tableDesc . reverseProperty = this ; tableDesc . idColumns . get ( 0 ) . columnName = reversePropDesc . columnName ; ArrayList < DBPropertyDescriptor > selectCols = new ArrayList < DBPropertyDescriptor > ( mainPropTable . idColumns ) ; for ( int i = 0 ; i < mainPropTable . columns . size ( ) ; i ++ ) { DBPropertyDescriptor mainProp = mainPropTable . columns . get ( i ) ; if ( mainProp == reversePropDesc ) continue ; selectCols . add ( mainProp ) ; } /*
                  if (dbTypeDesc.runtimeMode && tableDesc.columns != null) {
                     // In runtime model, the tables have already been set up with the right columns but we do need to initialize them here
                     if (false && selectCols.size() == tableDesc.columns.size()) {
                        for (DBPropertyDescriptor selectCol:tableDesc.columns)
                           selectCol.init(selectCol.dbTypeDesc, tableDesc);
                     }
                     else {
                        tableDesc.columns = selectCols;
                     }
                  }
                  else {
                  */ tableDesc . columns = selectCols ; for ( DBPropertyDescriptor selectCol : selectCols ) selectCol . init ( selectCol . dbTypeDesc , tableDesc ) ; } } } } }
This is called when we determine that this property's value is derived from the table provided.
This is called when we determine that this property ' s value is derived from the table provided .
// this likely means we are in runtimeMode - we set this table up in the compiled definition // The id property in this side's table is the value column in the reverse table // The value column for this property is the reverse table's id column - TODO: deal with multi column primary keys by overriding this in MultiColPropertyDescriptor // We are going to turn mainPropTable into a many-to-many table using mainProp's join name // Create the table descriptor for the many side of a one-to-many case // First select the reverse props id as part of the reference so we can create the instance // Then select all of the properties in the default table for the reverse side of the reference //}