1
0
mirror of synced 2025-01-29 19:41:45 +03:00

refactory ResultSetMappingBuilder#addNamedNativeQueryMapping into small submethods

This commit is contained in:
Fabio B. Silva 2012-03-06 21:17:35 -03:00
parent 8c407af1fc
commit fdc9fdae3e

View File

@ -109,7 +109,7 @@ class ResultSetMappingBuilder extends ResultSetMapping
/**
* Adds a the mappings of the results of native SQL queries to the result set.
* Adds the mappings of the results of native SQL queries to the result set.
*
* @param ClassMetadataInfo $class
* @param array $queryMapping
@ -118,7 +118,23 @@ class ResultSetMappingBuilder extends ResultSetMapping
public function addNamedNativeQueryMapping(ClassMetadataInfo $class, array $queryMapping)
{
if (isset($queryMapping['resultClass'])) {
$classMetadata = $this->em->getClassMetadata($queryMapping['resultClass']);
return $this->addNamedNativeQueryResultClassMapping($class, $queryMapping['resultClass']);
}
return $this->addNamedNativeQueryResultSetMapping($class, $queryMapping['resultSetMapping']);
}
/**
* Adds the class mapping of the results of native SQL queries to the result set.
*
* @param ClassMetadataInfo $class
* @param string $resultClassName
* @return ResultSetMappingBuilder
*/
public function addNamedNativeQueryResultClassMapping(ClassMetadataInfo $class, $resultClassName)
{
$classMetadata = $this->em->getClassMetadata($resultClassName);
$shortName = $classMetadata->reflClass->getShortName();
$alias = strtolower($shortName[0]).'0';
@ -147,7 +163,16 @@ class ResultSetMappingBuilder extends ResultSetMapping
return $this;
}
$resultMapping = $class->getSqlResultSetMapping($queryMapping['resultSetMapping']);
/**
* Adds the result set mapping of the results of native SQL queries to the result set.
*
* @param ClassMetadataInfo $class
* @param string $resultSetMappingName
* @return ResultSetMappingBuilder
*/
public function addNamedNativeQueryResultSetMapping(ClassMetadataInfo $class, $resultSetMappingName)
{
$resultMapping = $class->getSqlResultSetMapping($resultSetMappingName);
if (isset($resultMapping['entities'])) {
foreach ($resultMapping['entities'] as $key => $entityMapping) {
$classMetadata = $this->em->getClassMetadata($entityMapping['entityClass']);