Returns a join table name.

@param string      $sourceEntity The source entity.
@param string      $targetEntity The target entity.
@param string|null $propertyName A property name.

@return string A join table name.
767816
public function joinTableName($sourceEntity, $targetEntity, $propertyName = null)
    {
        $names = [
            $this->classToFieldName($sourceEntity),
            $this->classToFieldName($targetEntity)
        ];

        sort($names);

        return implode('_', $names);
    }
356230
protected function joinColumnToArray(ORM\JoinColumn $joinColumnAnnotation, $propertyName = null)
    {
        return [
            'name' => $joinColumnAnnotation->name === null ? $propertyName : $joinColumnAnnotation->name,
            'unique' => $joinColumnAnnotation->unique,
            'nullable' => $joinColumnAnnotation->nullable,
            'onDelete' => $joinColumnAnnotation->onDelete,
            'columnDefinition' => $joinColumnAnnotation->columnDefinition,
            'referencedColumnName' => $joinColumnAnnotation->referencedColumnName,
        ];
    }
280969
protected org.apache.lucene.search.Query makeTypeQuery(org.apache.lucene.search.Query query, String targetEntityName) {
      return query;
   }
705633
private function getManyToManyStatement(
        ManyToManyAssociationMetadata $association,
        $sourceEntity,
        $offset = null,
        $limit = null
    ) {
        $this->switchPersisterContext($offset, $limit);

        /** @var ClassMetadata $sourceClass */
        $sourceClass = $this->em->getClassMetadata($association->getSourceEntity());
        $class       = $sourceClass;
        $owningAssoc = $association;
        $criteria    = [];
        $parameters  = [];

        if (! $association->isOwningSide()) {
            $class       = $this->em->getClassMetadata($association->getTargetEntity());
            $owningAssoc = $class->getProperty($association->getMappedBy());
        }

        $joinTable     = $owningAssoc->getJoinTable();
        $joinTableName = $joinTable->getQuotedQualifiedName($this->platform);
        $joinColumns   = $association->isOwningSide()
            ? $joinTable->getJoinColumns()
            : $joinTable->getInverseJoinColumns();

        foreach ($joinColumns as $joinColumn) {
            $quotedColumnName = $this->platform->quoteIdentifier($joinColumn->getColumnName());
            $fieldName        = $sourceClass->fieldNames[$joinColumn->getReferencedColumnName()];
            $property         = $sourceClass->getProperty($fieldName);
            $value            = null;

            if ($property instanceof FieldMetadata) {
                $value = $property->getValue($sourceEntity);
            } elseif ($property instanceof AssociationMetadata) {
                $property    = $sourceClass->getProperty($fieldName);
                $targetClass = $this->em->getClassMetadata($property->getTargetEntity());
                $value       = $property->getValue($sourceEntity);

                $value = $this->em->getUnitOfWork()->getEntityIdentifier($value);
                $value = $value[$targetClass->identifier[0]];
            }

            $criteria[$joinTableName . '.' . $quotedColumnName] = $value;
            $parameters[]                                       = [
                'value' => $value,
                'field' => $fieldName,
                'class' => $sourceClass,
            ];
        }

        $sql = $this->getSelectSQL($criteria, $association, null, $limit, $offset);

        [$params, $types] = $this->expandToManyParameters($parameters);

        return $this->conn->executeQuery($sql, $params, $types);
    }
1069281
public final function join($tableName, $targetTableName = null, $alias = null)
    {
        return new QueryHelper\QueryJoin($this, $tableName, 'JOIN', $targetTableName, $alias);
    }
191315
public function getPrimaryKeyName($rootEntity)
    {
        $connection = $this->queryBuilder->getConnection();
        $databasePlatformName = $connection->getDatabasePlatform()->getName();
        $query = null;
        switch ($databasePlatformName) {
            case 'postgresql':
                /** @noinspection SpellCheckingInspection */
                $query = sprintf(
                    "%s %s %s",
                    "SELECT a.attname FROM pg_index i",
                    "JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)",
                    "WHERE  i.indrelid = ?::regclass AND i.indisprimary"
                );
                $stmt = $connection->executeQuery($query, [$rootEntity], [\PDO::PARAM_STR]);

                return $stmt->fetchColumn();
            case 'mysql':
                $query = sprintf(
                    "%s %s %s %s",
                    "SELECT k.column_name FROM information_schema.table_constraints t",
                    "JOIN information_schema.key_column_usage k USING(constraint_name,table_schema,table_name)",
                    "WHERE t.constraint_type='PRIMARY KEY' AND t.table_schema=?",
                    "AND t.table_name=?;"
                );
                $stmt = $connection->executeQuery(
                    $query,
                    [$rootEntity, $connection->getDatabase()],
                    [\PDO::PARAM_STR, \PDO::PARAM_STR]
                );

                return $stmt->fetchColumn();
            case 'sqlite':
                $query = "PRAGMA table_info(".$rootEntity.")";
                $stmt = $connection->executeQuery($query);
                while ($row = $stmt->fetch()) {
                    if ($row['pk']) {
                        return $row['name'];
                    }
                }
        }

        return null;
    }
663357
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        $parsedTargetType = TypeHandling::parseType($targetType);
        return $parsedTargetType['elementType'];
    }
1284535
public function getRelationTableForJoin($fullName) {
        if (!$this->tableName) {
            $class = $this->model;
            $this->tableName = $class::getTableName();
        }
        return "`" . $this->tableName . "` as  `" . ($this->tableAlias = str_replace('.', '_', $fullName)) . "`";
    }
1188891
protected function getFieldParams($fieldName = null, $entityName = null, $isOrmEntityDefs = false, $returns = null)
    {
        if (!isset($fieldName)) {
            $fieldName = $this->getFieldName();
        }
        if (!isset($entityName)) {
            $entityName = $this->getEntityName();
        }

        $entityDefs = $this->getDefs($isOrmEntityDefs);

        if (isset($entityDefs[$entityName]) && isset($entityDefs[$entityName]['fields'][$fieldName])) {
            return $entityDefs[$entityName]['fields'][$fieldName];
        }

        return $returns;
    }
241163
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(\Neos\Flow\Property\TypeConverter\PersistentObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
        if ($configuredTargetType !== null) {
            return $configuredTargetType;
        }

        $schema = $this->reflectionService->getClassSchema($targetType);
        $setterMethodName = ObjectAccess::buildSetterMethodName($propertyName);
        $constructorParameters = $this->reflectionService->getMethodParameters($targetType, '__construct');

        if (isset($constructorParameters[$propertyName]) && isset($constructorParameters[$propertyName]['type'])) {
            return $constructorParameters[$propertyName]['type'];
        } elseif ($schema->hasProperty($propertyName)) {
            $propertyInformation = $schema->getProperty($propertyName);
            return $propertyInformation['type'] . ($propertyInformation['elementType'] !== null ? '<' . $propertyInformation['elementType'] . '>' : '');
        } elseif ($this->reflectionService->hasMethod($targetType, $setterMethodName)) {
            $methodParameters = $this->reflectionService->getMethodParameters($targetType, $setterMethodName);
            $methodParameter = current($methodParameters);
            if (!isset($methodParameter['type'])) {
                throw new InvalidTargetException('Setter for property "' . $propertyName . '" had no type hint or documentation in target object of type "' . $targetType . '".', 1303379158);
            } else {
                return $methodParameter['type'];
            }
        } else {
            throw new InvalidTargetException('Property "' . $propertyName . '" was not found in target object of type "' . $targetType . '".', 1297978366);
        }
    }
104766
public static function mergeArrayIntoEntity($targetEntity, $array)
    {
        foreach ($array as $property => $value) {
            if (!empty($value)) {
                if (is_a($targetEntity->{'get' . ucfirst($property)}(),
                    '\\TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage')
                ) {
                    $targetEntity->{'set' . ucfirst($property)}(new ObjectStorage());
                    if (is_array($value)) {
                        $singular = (preg_match('~s$~i', $property) > 0) ? rtrim($property, 's') : sprintf('%ss',
                            $property);
                        foreach ($value as $item) {
                            $targetEntity->{'add' . ucfirst($singular)}($item);
                        }
                    }
                } else {
                    $targetEntity->{'set' . ucfirst($property)}($value);
                }
            }
        }

        return $targetEntity;
    }
532887
public function addInverseOneToOne($name, $targetEntity, $mappedBy)
    {
        $builder = $this->createOneToOne($name, $targetEntity);
        $builder->mappedBy($mappedBy);

        return $builder->build();
    }
43302
public function getColumnValue($entity, string $columnName)
    {
        // Looking for fields by column is the easiest way to look at local columns or x-1 owning side associations
        $propertyName = $this->class->fieldNames[$columnName];
        $property     = $this->class->getProperty($propertyName);

        if (! $property) {
            return null;
        }

        $propertyValue = $property->getValue($entity);

        if ($property instanceof LocalColumnMetadata) {
            return $propertyValue;
        }

        /** @var ToOneAssociationMetadata $property */
        $unitOfWork      = $this->em->getUnitOfWork();
        $targetClass     = $this->em->getClassMetadata($property->getTargetEntity());
        $targetPersister = $unitOfWork->getEntityPersister($property->getTargetEntity());

        foreach ($property->getJoinColumns() as $joinColumn) {
            /** @var JoinColumnMetadata $joinColumn */
            $referencedColumnName = $joinColumn->getReferencedColumnName();

            if (! $joinColumn->getType()) {
                $joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $targetClass, $this->em));
            }

            if ($joinColumn->getColumnName() !== $columnName) {
                continue;
            }

            return $targetPersister->getColumnValue($propertyValue, $referencedColumnName);
        }

        return null;
    }
645655
private String getPropertyName(final String targetTypeName, final boolean outgoing, final String relationshipTypeName, final Cardinality cardinality) {

		final String sourceTypeName   = getName();
		final String relatedClassName = outgoing ? targetTypeName : sourceTypeName;

		String _sourceMultiplicity = null;
		String _targetMultiplicity = null;

		switch (cardinality) {

			case OneToOne:
				_sourceMultiplicity = "1";
				_targetMultiplicity = "1";
				break;

			case OneToMany:
				_sourceMultiplicity = "1";
				_targetMultiplicity = "*";
				break;

			case ManyToOne:
				_sourceMultiplicity = "*";
				_targetMultiplicity = "1";
				break;

			case ManyToMany:
				_sourceMultiplicity = "*";
				_targetMultiplicity = "*";
				break;
		}

		return SchemaRelationshipNode.getPropertyName(relatedClassName, root.getExistingPropertyNames(), outgoing, relationshipTypeName, sourceTypeName, targetTypeName, null, _targetMultiplicity, null, _sourceMultiplicity);
	}
79460
public function getProperty($source, $propertyName) {
        foreach ($this->getPropertyAccessors() as $accessor) {
            if ($accessor->supports($source, $propertyName)) {
                return $accessor->getProperty($source, $propertyName);
            }
        }

        return null;
    }
624066
public function getTargetPropertyName($sourcePropertyName)
    {
        if (isset($this->mapping[$sourcePropertyName])) {
            return $this->mapping[$sourcePropertyName];
        }
        return $sourcePropertyName;
    }
104229
public String collectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity,
      String associatedEntityTable, String propertyName) {
    String ownerTable = null;
    Class<?> entityClass = null;
    try {
      entityClass = Class.forName(ownerEntity);
    } catch (ClassNotFoundException e) {
    }
    // Just for annotation configuration,it's ownerEntity is classname(not entityName), and
    // ownerEntityTable is class shortname
    if (Character.isUpperCase(ownerEntityTable.charAt(0))) {
      ownerTable = tableNamingStrategy.classToTableName(entityClass);
    } else {
      ownerTable = tableName(ownerEntityTable);
    }
    String tblName = tableNamingStrategy.collectionToTableName(entityClass, ownerTable, propertyName);
    if (tblName.length() > MaxLength) logger.warn("{}'s length greate than 30!", tblName);
    return tblName;
  }