prepareCacheQuery( );
	protected void populateOdiQuery( ) throws DataException	{		assert odiQuery != null;		assert this.baseQueryDefn != null;		Context cx = Context.enter( );		try		{			// Set grouping			populateGrouping( cx );			// Set sorting			List sorts = this.baseQueryDefn.getSorts( );			if ( sorts != null && !sorts.isEmpty( ) )			{				IQuery.SortSpec[] sortSpecs = new IQuery.SortSpec[sorts.size( )];				Iterator it = sorts.iterator( );				for ( int i = 0; it.hasNext( ); i++ )				{					ISortDefinition src = (ISortDefinition) it.next( );					int sortIndex = -1;					String sortKey = src.getColumn( );					if ( sortKey == null )						sortKey = src.getExpression( ).getText( );					else					{						sortKey = getColumnRefExpression( sortKey );					}					temporaryComputedColumns.add( new ComputedColumn( "_{$TEMP_SORT_"							+ i + "$}_",							sortKey,							DataType.ANY_TYPE ) );					sortIndex = -1;					sortKey = String.valueOf( "_{$TEMP_SORT_" + i + "$}_" );					IQuery.SortSpec dest = new IQuery.SortSpec( sortIndex,							sortKey,							src.getSortDirection( ) == ISortDefinition.SORT_ASC );					sortSpecs[i] = dest;				}				odiQuery.setOrdering( Arrays.asList( sortSpecs ) );			}			// set filter event			List dataSetFilters = new ArrayList( );			List queryFilters = new ArrayList( );			if ( dataSet.getFilters( ) != null )			{				dataSetFilters = dataSet.getFilters( );			}			if ( this.baseQueryDefn.getFilters( ) != null )			{				for ( int i = 0; i < this.baseQueryDefn.getFilters( ).size( ); i++ )				{					queryFilters.add( this.baseQueryDefn.getFilters( ).get( i ) );				}			}			//When prepare filters, the temporaryComputedColumns would also be effect.			List multipassFilters = prepareFilters( cx,					dataSetFilters,					queryFilters,					temporaryComputedColumns );			//******************populate the onFetchEvent below**********************/		    			List computedColumns = null;			// set computed column event			computedColumns = this.dataSet.getComputedColumns( );			if ( computedColumns == null )				computedColumns = new ArrayList( );			if ( computedColumns.size( ) > 0					|| temporaryComputedColumns.size( ) > 0 )			{				IResultObjectEvent objectEvent = new ComputedColumnHelper( this.dataSet,						computedColumns,						temporaryComputedColumns );				odiQuery.addOnFetchEvent( objectEvent );				this.dataSet.getComputedColumns( )						.addAll( temporaryComputedColumns );			}			if ( dataSet.getEventHandler( ) != null )			{				OnFetchScriptHelper event = new OnFetchScriptHelper( dataSet );				odiQuery.addOnFetchEvent( event );			}			if ( dataSetFilters.size( )					+ queryFilters.size( ) + multipassFilters.size( ) > 0 )			{				IResultObjectEvent objectEvent = new FilterByRow( dataSetFilters,						queryFilters,						multipassFilters,						dataSet );				odiQuery.addOnFetchEvent( objectEvent );			}			// specify max rows the query should fetch			odiQuery.setMaxRows( this.baseQueryDefn.getMaxRows( ) );		}		finally		{			Context.exit( );		}	}