private ColumnDef addColumnFor ( FieldDescriptorDef fieldDef , TableDef tableDef ) { String name = fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_COLUMN ) ; ColumnDef columnDef = tableDef . getColumn ( name ) ; if ( columnDef == null ) { columnDef = new ColumnDef ( name ) ; tableDef . addColumn ( columnDef ) ; } if ( ! fieldDef . isNested ( ) ) { columnDef . setProperty ( PropertyHelper . TORQUE_PROPERTY_JAVANAME , fieldDef . getName ( ) ) ; } columnDef . setProperty ( PropertyHelper . TORQUE_PROPERTY_TYPE , fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_JDBC_TYPE ) ) ; columnDef . setProperty ( PropertyHelper . TORQUE_PROPERTY_ID , fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_ID ) ) ; if ( fieldDef . getBooleanProperty ( PropertyHelper . OJB_PROPERTY_PRIMARYKEY , false ) ) { columnDef . setProperty ( PropertyHelper . TORQUE_PROPERTY_PRIMARYKEY , "true" ) ; columnDef . setProperty ( PropertyHelper . TORQUE_PROPERTY_REQUIRED , "true" ) ; } else if ( ! fieldDef . getBooleanProperty ( PropertyHelper . OJB_PROPERTY_NULLABLE , true ) ) { columnDef . setProperty ( PropertyHelper . TORQUE_PROPERTY_REQUIRED , "true" ) ; } if ( "database" . equals ( fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_AUTOINCREMENT ) ) ) { columnDef . setProperty ( PropertyHelper . TORQUE_PROPERTY_AUTOINCREMENT , "true" ) ; } columnDef . setProperty ( PropertyHelper . TORQUE_PROPERTY_SIZE , fieldDef . getSizeConstraint ( ) ) ; if ( fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_DOCUMENTATION ) ) { columnDef . setProperty ( PropertyHelper . OJB_PROPERTY_DOCUMENTATION , fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_DOCUMENTATION ) ) ; } if ( fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_COLUMN_DOCUMENTATION ) ) { columnDef . setProperty ( PropertyHelper . OJB_PROPERTY_COLUMN_DOCUMENTATION , fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_COLUMN_DOCUMENTATION ) ) ; } return columnDef ; }
Generates a column for the given field and adds it to the table .