protected function unserialize(\Asgard\Entity\Entity $entity, array $data, $locale=null) {
		foreach($this->dataMapper->getEntityDefinition($entity)->properties() as $k=>$prop) {
			$v = isset($data[$k]) ? $data[$k]:null;

			if($prop->get('type') === 'entity') {
				if($prop->get('many'))
					$data[$k] = new PersistentCollection($entity, $k, $this->dataMapper);
				else {
					$entity_id = $k.'_id';
					$id = $data[$entity_id];
					if($id) {
						if($prop->get('entity'))
							$class = $prop->get('entity');
						else {
							$entity_class = $k.'_type';
							$class = $data[$entity_class];
						}
						$data[$k] = $this->dataMapper->createEntityProxy($class, $id);
					}
					else
						$data[$k] = null;
				}
			}
			else {
				$class = get_class($prop);
				if($prop->get('many'))
					$data[$k] = $this->dataMapper->getEntityDefinition($entity)->property($k)->unserialize($v, $entity, $k);
				elseif($v === null)
					$data[$k] = null;
				elseif(method_exists($prop, 'fromSQL'))
					$data[$k] = $prop->fromSQL($v);
				elseif($transformer = $this->dataMapper->getSqlInput($class))
					return $transformer->fromSQL($v);
				else
					$data[$k] = $this->dataMapper->getEntityDefinition($entity)->property($k)->unserialize($v, $entity, $k);
			}
		}

		return $entity->_set($data, $locale, null, false);
	}