private void tableJoins ( String pColumn , boolean pWhereJoin ) { String join = null ; String table = null ; if ( pColumn == null ) { // Identity join = getIdentityJoin ( ) ; table = getTable ( getProperty ( getPrimaryKey ( ) ) ) ; } else { // Normal int dotIndex = - 1 ; if ( ( dotIndex = pColumn . lastIndexOf ( "." ) ) <= 0 ) { // No table qualifier return ; } // Get table qualifier. table = pColumn . substring ( 0 , dotIndex ) ; // Don't care about the tables that are not supposed to be selected from String property = ( String ) getProperty ( pColumn ) ; if ( property != null ) { String mapType = ( String ) mMapTypes . get ( property ) ; if ( ! pWhereJoin && mapType != null && ! mapType . equals ( DIRECTMAP ) ) { return ; } join = ( String ) mJoins . get ( property ) ; } } // If table is not in the tables Hash, add it, and check for joins. if ( mTables . get ( table ) == null ) { if ( join != null ) { mTables . put ( table , join ) ; StringTokenizer tok = new StringTokenizer ( join , "= " ) ; String next = null ; while ( tok . hasMoreElements ( ) ) { next = tok . nextToken ( ) ; // Don't care about SQL keywords if ( next . equals ( "AND" ) || next . equals ( "OR" ) || next . equals ( "NOT" ) || next . equals ( "IN" ) ) { continue ; } // Check for new tables and joins in this join clause. tableJoins ( next , false ) ; } } else { // No joins for this table. join = "" ; mTables . put ( table , join ) ; } } }
Finds tables used in mappings and joins and adds them to the tables Hashtable with the table name as key and the join as value .