public function fetchRelationData($tableEntity, $config)
 {
     $entityCfg = $tableEntity->getConfig();
     $key = $tableEntity->{$config}['key'];
     $config['class'] = new $config['class']();
     $fileds = $config['class']->getFileds();
     $relateCfg = $config['class']->getConfig();
     if ($fileds[0] == '*') {
         $fileds = $relateCfg['columns'];
     }
     $crit = null;
     if (isset($config['criteria']) && is_object($config['criteria'])) {
         $crit = $config['criteria'];
     } else {
         $crit = new self($config['class']);
         $crit->setFileds($fileds);
     }
     $crit->add(Criteria::_AND, Restrictions::eq($config['column'], $key));
     $cache = CacheManager::getInstance();
     /*
             缓存机制需要实现 by Alan 20130301
             $sql = $crit->sql();
     		$parmas = $crit->getParameters();
     
     		$data = $cache->get(CriteriaQuery::getDumpSQL($sql, $parmas));
     		if($data){
     			return $data;
     		}*/
     $totalNum = 0;
     $fileds = $crit->getFileds();
     $projectionEntitys = $crit->getProjectionEntitys();
     $dataPager = $crit->getDataPager();
     //获取分页器
     if (isset($projectionEntitys) && count($projectionEntitys) > 0) {
         $crit->cleanFileds();
         $crit->cleanLimit();
         $rs1 = $crit->_array(false);
         $totalNum = @current(@current($rs1));
         if (is_object($dataPager)) {
             $dataPager->setTotalNum($totalNum);
         }
         $crit->cleanProjection();
     }
     $crit->setFileds($fileds);
     if (is_object($dataPager)) {
         $crit->setFirstResult($dataPager->getFirstResult());
         $crit->setFetchSize($dataPager->getPageSize());
     }
     $rs = $crit->_array(false);
     if ($rs) {
         $class = get_class($config['class']);
         if ($config['relation'] == 'one-to-one') {
             $rs = current($rs);
             $data = new $class();
             $data->setFileds($fileds);
             foreach ($rs as $k => $v) {
                 $data->{$k} = $v;
             }
             //检查多级关联
             $cfgl = $data->getRelationPro();
             if (isset($cfgl) && is_array($cfgl)) {
                 foreach ($cfgl as $pro => $cfg) {
                     if (!isset($cfg['lazy']) || !$cfg['lazy'] == true) {
                         $data->{$cfg}['name'] = $this->fetchRelationData($data, $cfg);
                     }
                 }
             }
             $data->setCriteria($this);
             //$cache->set(CriteriaQuery::getDumpSQL($sql, $parmas),$data);
             return $data;
         } else {
             $dataList = array();
             foreach ($rs as $i => $item) {
                 $data = new $class();
                 $data->setFileds($fileds);
                 foreach ($item as $k => $v) {
                     $data->{$k} = $v;
                 }
                 $data->setCriteria($this);
                 //检查多级关联
                 $cfgl = $data->getRelationPro();
                 if (isset($cfgl) && is_array($cfgl)) {
                     foreach ($cfgl as $pro => $cfg) {
                         if (!isset($cfg['lazy']) || !$cfg['lazy'] == true) {
                             $data->{$cfg}['name'] = $this->fetchRelationData($data, $cfg);
                         }
                     }
                 }
                 array_push($dataList, $data);
             }
             return $dataList;
         }
     }
     //}
     return null;
 }