private final function load($sql, $bind = array()) { $sql = $this->makeSqlIsolated($sql); $rowSet = $this->getDb()->query($sql, $bind); if (empty($rowSet)) { if (is_callable(array($this->className, 'getNotExistMsg'))) { $msg = call_user_func(array($this->className, 'getNotExistMsg')); } else { $msg = NullEntity::getNotExistMsg(); } return new NullEntity($msg); } $identityMap = BeanFinder::get('LocalCache'); $entity = $identityMap->find($this->className, $rowSet[0][$this->getIdColumn()]); if (empty($entity)) { $entity = $this->row2Object($rowSet[0]); $identityMap->update($this->className, $entity->id, $entity); } return $entity; }