Skip to content

Loading…

DDC-2387: convert-mapping not working correctly with composite primary keys/foreign keys in 2.4.0-RC1 #3097

Open
doctrinebot opened this Issue · 13 comments

2 participants

@doctrinebot

Jira issue originally created by user succinct:

(Apologies if this is somehow a Symfony-specific issue)

I updated my application via Composer yesterday, and received Doctrine 2.4.0-RC1. After this update, generating entities has been problematic under certain circumstances.

Here is an example table in MySQL:

CREATE TABLE `user_email` (
  `user_id` int(10) unsigned NOT NULL COMMENT 'FK to user',
  `email` varchar(254) NOT NULL,
  `email*datasource` smallint(1) unsigned NOT NULL COMMENT 'FK to datasource*code',
  `insert_date` datetime NOT NULL,
  PRIMARY KEY (`user*id`,`email`,`email*datasource`),
  KEY `FK*UserEmail_DataSourceCode` (`email*datasource`),
  CONSTRAINT `FK*UserEmail_User` FOREIGN KEY (`user*id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

In Doctrine 2.3, the mapping works correctly, and you end up with a 3-part primary key, with a user property mapped to the User entity, and a datasourceCode property mapped to the DatasourceCode entity. All good.

In 2.4, the following error is given: Single id is not allowed on composite primary key in entity UserEmail.

Removing one of the foreign keys in the table (either to User or DatasourceCode) but keeping the primary key set to all 3 columns allows the mapping to work. But_, if you then remove one of the columns from the primary key (say, emaildatasource) it fails again.

@doctrinebot

Comment created by @beberlei:

Can you provide the full stack trace to the exception please?

$e->getTraceAsString();
@doctrinebot

Comment created by succinct:

Benjamin, I'm not sure how to get the trace for you, since I'm running from inside the Symfony2 doctrine:mapping:import command line item.

@doctrinebot

Comment created by stof:

Use the --verbose option when running the command

@doctrinebot

Comment created by succinct:

I was able to get a trace for you:

#0 /var/www/html/voxrepublic/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php(1571): Doctrine\ORM\Mapping\MappingException::singleIdNotAllowedOnCompositePrimaryKey('UserEmail')
#1 /var/www/html/voxrepublic/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(422): Doctrine\ORM\Mapping\ClassMetadataInfo->getSingleIdentifierFieldName()
#2 /var/www/html/voxrepublic/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(136): Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping(Object(Doctrine\ORM\Mapping\ClassMetadata))
#3 /var/www/html/voxrepublic/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(302): Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata(Object(Doctrine\ORM\Mapping\ClassMetadata), NULL, false, Array)
#4 /var/www/html/voxrepublic/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(212): Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata('UserEmail')
#5 /var/www/html/voxrepublic/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(112): Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('UserEmail')
#6 /var/www/html/voxrepublic/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Command/ImportMappingDoctrineCommand.php(108): Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata()
#7 /var/www/html/voxrepublic/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(240): Doctrine\Bundle\DoctrineBundle\Command\ImportMappingDoctrineCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/html/voxrepublic/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/html/voxrepublic/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(78): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/voxrepublic/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(106): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/voxrepublic/app/console(22): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#12 {main}
@doctrinebot

Comment created by @beberlei:

The problem is that Doctrine seems to detect that you only have on id field on this entity and then a new function of 2.4 throws this error. I will try to reproduce this with your table. Until then could you show me the var_dump() of the $class variable in Doctrine\ORM\ClassMetadataFactory#completeIdGeneratorMapping()? This would help very much already.

@doctrinebot

Comment created by maximilian:

I have the same error when using "doctrine:mapping:import"
``CREATE TABLE IF NOT EXISTSdev_Recipe.step` (

recipe_id INT NOT NULL ,

step_number INT NOT NULL ,

description TEXT NULL ,

timer INT NULL ,

image VARCHAR(100) NULL ,

PRIMARY KEY (recipe*id, step*number) ,

INDEX recipe*id_idx (recipe*id ASC) ,

INDEX step*number (step*number ASC) ,

CONSTRAINT step*recipe*id

FOREIGN KEY (`recipe_id` )

REFERENCES `dev*Recipe`.`recipe` (`recipe*id` )

ON DELETE NO ACTION

ON UPDATE NO ACTION)

ENGINE = InnoDB;```

Exception trace:
() at \htdocs\SF2\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\MappingException.php:258
Doctrine\ORM\Mapping\MappingException::singleIdNotAllowedOnCompositePrimaryKey() at \htdocs\SF2\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php:1571
Doctrine\ORM\Mapping\ClassMetadataInfo->getSingleIdentifierFieldName() at \htdocs\SF2\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php:422
Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping() at \htdocs\SF2\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php:136
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at \htdocs\SF2\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php:302
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at \htdocs\SF2\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php:212
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at \htdocs\SF2\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php:112
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() at \htdocs\SF2\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand.php:126
Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand->execute() at \htdocs\SF2\vendor\doctrine\doctrine-bundle\Doctrine\Bundle\DoctrineBundle\Command\Proxy\ConvertMappingDoctrineCommand.php:59
Doctrine\Bundle\DoctrineBundle\Command\Proxy\ConvertMappingDoctrineCommand->execute() at \htdocs\SF2\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:240
Symfony\Component\Console\Command\Command->run() at \htdocs\SF2\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:193
Symfony\Component\Console\Application->doRun() at \htdocs\SF2\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:78
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at \htdocs\SF2\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:106
Symfony\Component\Console\Application->run() at \htdocs\SF2\app\console:22

"var_dump($class);" returns:
object(Doctrine\ORM\Mapping\ClassMetadata)#470 (36) {
["name"]=>
string(10) "Ingredient"
["namespace"]=>
string(0) ""
["rootEntityName"]=>
string(10) "Ingredient"
["customGeneratorDefinition"]=>
NULL
["customRepositoryClassName"]=>
NULL
["isMappedSuperclass"]=>
bool(false)
["parentClasses"]=>
array(0) {
}
["subClasses"]=>
array(0) {
}
["namedQueries"]=>
array(0) {
}
["namedNativeQueries"]=>
array(0) {
}
["sqlResultSetMappings"]=>
array(0) {
}
["identifier"]=>
array(1) {
[0]=>
string(12) "ingredientId"
}
["inheritanceType"]=>
int(1)
["generatorType"]=>
int(1)
["fieldMappings"]=>
array(4) {
["ingredientId"]=>
array(6) {
["id"]=>
bool(true)
["fieldName"]=>
string(12) "ingredientId"
["columnName"]=>
string(13) "ingredient_id"
["type"]=>
string(7) "integer"
["unsigned"]=>
bool(false)
["nullable"]=>
bool(false)
}
["name"]=>
array(6) {
["fieldName"]=>
string(4) "name"
["columnName"]=>
string(4) "name"
["type"]=>
string(6) "string"
["length"]=>
int(45)
["fixed"]=>
bool(false)
["nullable"]=>
bool(false)
}
["color"]=>
array(5) {
["fieldName"]=>
string(5) "color"
["columnName"]=>
string(5) "color"
["type"]=>
string(7) "integer"
["unsigned"]=>
bool(false)
["nullable"]=>
bool(false)
}
["img"]=>
array(6) {
["fieldName"]=>
string(3) "img"
["columnName"]=>
string(3) "img"
["type"]=>
string(6) "string"
["length"]=>
int(45)
["fixed"]=>
bool(false)
["nullable"]=>
bool(true)
}
}
["fieldNames"]=>
array(4) {
["ingredient_id"]=>
string(12) "ingredientId"
["name"]=>
string(4) "name"
["color"]=>
string(5) "color"
["img"]=>
string(3) "img"
}
["columnNames"]=>
array(4) {
["ingredientId"]=>
string(13) "ingredient_id"
["name"]=>
string(4) "name"
["color"]=>
string(5) "color"
["img"]=>
string(3) "img"
}
["discriminatorValue"]=>
NULL
["discriminatorMap"]=>
array(0) {
}
["discriminatorColumn"]=>
NULL
["table"]=>
array(1) {
["name"]=>
string(10) "ingredient"
}
["lifecycleCallbacks"]=>
array(0) {
}
["associationMappings"]=>
array(1) {
["ingredientCategory"]=>
array(15) {
["fieldName"]=>
string(18) "ingredientCategory"
["targetEntity"]=>
string(18) "IngredientCategory"
["mappedBy"]=>
string(10) "ingredient"
["type"]=>
int(8)
["inversedBy"]=>
NULL
["isOwningSide"]=>
bool(false)
["sourceEntity"]=>
string(10) "Ingredient"
["fetch"]=>
int(2)
["cascade"]=>
array(0) {
}
["isCascadeRemove"]=>
bool(false)
["isCascadePersist"]=>
bool(false)
["isCascadeRefresh"]=>
bool(false)
["isCascadeMerge"]=>
bool(false)
["isCascadeDetach"]=>
bool(false)
["orphanRemoval"]=>
bool(false)
}
}
["isIdentifierComposite"]=>
bool(false)
["containsForeignIdentifier"]=>
bool(false)
["idGenerator"]=>
NULL
["sequenceGeneratorDefinition"]=>
NULL
["tableGeneratorDefinition"]=>
NULL
["changeTrackingPolicy"]=>
int(1)
["isVersioned"]=>
NULL
["versionField"]=>
NULL
["reflClass"]=>
NULL
["isReadOnly"]=>
bool(false)
["namingStrategy":protected]=>
object(Doctrine\ORM\Mapping\DefaultNamingStrategy)#258 (0) {
}
["reflFields"]=>
array(0) {
}
["_prototype":"Doctrine\ORM\Mapping\ClassMetadataInfo":private]=>
NULL
}
object(Doctrine\ORM\Mapping\ClassMetadata)#472 (36) {
["name"]=>
string(18) "IngredientCategory"
["namespace"]=>
string(0) ""
["rootEntityName"]=>
string(18) "IngredientCategory"
["customGeneratorDefinition"]=>
NULL
["customRepositoryClassName"]=>
NULL
["isMappedSuperclass"]=>
bool(false)
["parentClasses"]=>
array(0) {
}
["subClasses"]=>
array(0) {
}
["namedQueries"]=>
array(0) {
}
["namedNativeQueries"]=>
array(0) {
}
["sqlResultSetMappings"]=>
array(0) {
}
["identifier"]=>
array(1) {
[0]=>
string(2) "id"
}
["inheritanceType"]=>
int(1)
["generatorType"]=>
int(1)
["fieldMappings"]=>
array(3) {
["id"]=>
array(6) {
["id"]=>
bool(true)
["fieldName"]=>
string(2) "id"
["columnName"]=>
string(2) "id"
["type"]=>
string(7) "integer"
["unsigned"]=>
bool(false)
["nullable"]=>
bool(false)
}
["name"]=>
array(6) {
["fieldName"]=>
string(4) "name"
["columnName"]=>
string(4) "name"
["type"]=>
string(6) "string"
["length"]=>
int(255)
["fixed"]=>
bool(false)
["nullable"]=>
bool(false)
}
["description"]=>
array(4) {
["fieldName"]=>
string(11) "description"
["columnName"]=>
string(11) "description"
["type"]=>
string(4) "text"
["nullable"]=>
bool(true)
}
}
["fieldNames"]=>
array(3) {
["id"]=>
string(2) "id"
["name"]=>
string(4) "name"
["description"]=>
string(11) "description"
}
["columnNames"]=>
array(3) {
["id"]=>
string(2) "id"
["name"]=>
string(4) "name"
["description"]=>
string(11) "description"
}
["discriminatorValue"]=>
NULL
["discriminatorMap"]=>
array(0) {
}
["discriminatorColumn"]=>
NULL
["table"]=>
array(1) {
["name"]=>
string(19) "ingredient_category"
}
["lifecycleCallbacks"]=>
array(0) {
}
["associationMappings"]=>
array(2) {
["ingredient"]=>
array(19) {
["fieldName"]=>
string(10) "ingredient"
["targetEntity"]=>
string(10) "Ingredient"
["inversedBy"]=>
string(18) "ingredientCategory"
["joinTable"]=>
array(3) {
["name"]=>
string(30) "ingredient*category*ingredient"
["joinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(22) "ingredient*category*id"
["referencedColumnName"]=>
string(2) "id"
}
}
["inverseJoinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(13) "ingredient_id"
["referencedColumnName"]=>
string(13) "ingredient_id"
}
}
}
["type"]=>
int(8)
["mappedBy"]=>
NULL
["isOwningSide"]=>
bool(true)
["sourceEntity"]=>
string(18) "IngredientCategory"
["fetch"]=>
int(2)
["cascade"]=>
array(0) {
}
["isCascadeRemove"]=>
bool(false)
["isCascadePersist"]=>
bool(false)
["isCascadeRefresh"]=>
bool(false)
["isCascadeMerge"]=>
bool(false)
["isCascadeDetach"]=>
bool(false)
["joinTableColumns"]=>
array(2) {
[0]=>
string(22) "ingredient*category*id"
[1]=>
string(13) "ingredient_id"
}
["relationToSourceKeyColumns"]=>
array(1) {
["ingredient*category*id"]=>
string(2) "id"
}
["relationToTargetKeyColumns"]=>
array(1) {
["ingredient_id"]=>
string(13) "ingredient_id"
}
["orphanRemoval"]=>
bool(false)
}
["parent"]=>
array(19) {
["fieldName"]=>
string(6) "parent"
["targetEntity"]=>
string(18) "IngredientCategory"
["joinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(9) "parent_id"
["referencedColumnName"]=>
string(2) "id"
}
}
["type"]=>
int(2)
["mappedBy"]=>
NULL
["inversedBy"]=>
NULL
["isOwningSide"]=>
bool(true)
["sourceEntity"]=>
string(18) "IngredientCategory"
["fetch"]=>
int(2)
["cascade"]=>
array(0) {
}
["isCascadeRemove"]=>
bool(false)
["isCascadePersist"]=>
bool(false)
["isCascadeRefresh"]=>
bool(false)
["isCascadeMerge"]=>
bool(false)
["isCascadeDetach"]=>
bool(false)
["sourceToTargetKeyColumns"]=>
array(1) {
["parent_id"]=>
string(2) "id"
}
["joinColumnFieldNames"]=>
array(1) {
["parent_id"]=>
string(9) "parent_id"
}
["targetToSourceKeyColumns"]=>
array(1) {
["id"]=>
string(9) "parent_id"
}
["orphanRemoval"]=>
bool(false)
}
}
["isIdentifierComposite"]=>
bool(false)
["containsForeignIdentifier"]=>
bool(false)
["idGenerator"]=>
NULL
["sequenceGeneratorDefinition"]=>
NULL
["tableGeneratorDefinition"]=>
NULL
["changeTrackingPolicy"]=>
int(1)
["isVersioned"]=>
NULL
["versionField"]=>
NULL
["reflClass"]=>
NULL
["isReadOnly"]=>
bool(false)
["namingStrategy":protected]=>
object(Doctrine\ORM\Mapping\DefaultNamingStrategy)#258 (0) {
}
["reflFields"]=>
array(0) {
}
["_prototype":"Doctrine\ORM\Mapping\ClassMetadataInfo":private]=>
NULL
}
object(Doctrine\ORM\Mapping\ClassMetadata)#474 (36) {
["name"]=>
string(6) "Recipe"
["namespace"]=>
string(0) ""
["rootEntityName"]=>
string(6) "Recipe"
["customGeneratorDefinition"]=>
NULL
["customRepositoryClassName"]=>
NULL
["isMappedSuperclass"]=>
bool(false)
["parentClasses"]=>
array(0) {
}
["subClasses"]=>
array(0) {
}
["namedQueries"]=>
array(0) {
}
["namedNativeQueries"]=>
array(0) {
}
["sqlResultSetMappings"]=>
array(0) {
}
["identifier"]=>
array(1) {
[0]=>
string(8) "recipeId"
}
["inheritanceType"]=>
int(1)
["generatorType"]=>
int(1)
["fieldMappings"]=>
array(3) {
["recipeId"]=>
array(6) {
["id"]=>
bool(true)
["fieldName"]=>
string(8) "recipeId"
["columnName"]=>
string(9) "recipe_id"
["type"]=>
string(7) "integer"
["unsigned"]=>
bool(false)
["nullable"]=>
bool(false)
}
["name"]=>
array(6) {
["fieldName"]=>
string(4) "name"
["columnName"]=>
string(4) "name"
["type"]=>
string(6) "string"
["length"]=>
int(255)
["fixed"]=>
bool(false)
["nullable"]=>
bool(false)
}
["description"]=>
array(4) {
["fieldName"]=>
string(11) "description"
["columnName"]=>
string(11) "description"
["type"]=>
string(4) "text"
["nullable"]=>
bool(true)
}
}
["fieldNames"]=>
array(3) {
["recipe_id"]=>
string(8) "recipeId"
["name"]=>
string(4) "name"
["description"]=>
string(11) "description"
}
["columnNames"]=>
array(3) {
["recipeId"]=>
string(9) "recipe_id"
["name"]=>
string(4) "name"
["description"]=>
string(11) "description"
}
["discriminatorValue"]=>
NULL
["discriminatorMap"]=>
array(0) {
}
["discriminatorColumn"]=>
NULL
["table"]=>
array(1) {
["name"]=>
string(6) "recipe"
}
["lifecycleCallbacks"]=>
array(0) {
}
["associationMappings"]=>
array(2) {
["recipeCategory"]=>
array(15) {
["fieldName"]=>
string(14) "recipeCategory"
["targetEntity"]=>
string(14) "RecipeCategory"
["mappedBy"]=>
string(6) "recipe"
["type"]=>
int(8)
["inversedBy"]=>
NULL
["isOwningSide"]=>
bool(false)
["sourceEntity"]=>
string(6) "Recipe"
["fetch"]=>
int(2)
["cascade"]=>
array(0) {
}
["isCascadeRemove"]=>
bool(false)
["isCascadePersist"]=>
bool(false)
["isCascadeRefresh"]=>
bool(false)
["isCascadeMerge"]=>
bool(false)
["isCascadeDetach"]=>
bool(false)
["orphanRemoval"]=>
bool(false)
}
["users"]=>
array(19) {
["fieldName"]=>
string(5) "users"
["targetEntity"]=>
string(5) "Users"
["inversedBy"]=>
string(12) "recipeRecipe"
["joinTable"]=>
array(3) {
["name"]=>
string(13) "users_recipes"
["joinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(16) "recipe*recipe*id"
["referencedColumnName"]=>
string(9) "recipe_id"
}
}
["inverseJoinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(8) "users_id"
["referencedColumnName"]=>
string(2) "id"
}
}
}
["type"]=>
int(8)
["mappedBy"]=>
NULL
["isOwningSide"]=>
bool(true)
["sourceEntity"]=>
string(6) "Recipe"
["fetch"]=>
int(2)
["cascade"]=>
array(0) {
}
["isCascadeRemove"]=>
bool(false)
["isCascadePersist"]=>
bool(false)
["isCascadeRefresh"]=>
bool(false)
["isCascadeMerge"]=>
bool(false)
["isCascadeDetach"]=>
bool(false)
["joinTableColumns"]=>
array(2) {
[0]=>
string(16) "recipe*recipe*id"
[1]=>
string(8) "users_id"
}
["relationToSourceKeyColumns"]=>
array(1) {
["recipe*recipe*id"]=>
string(9) "recipe_id"
}
["relationToTargetKeyColumns"]=>
array(1) {
["users_id"]=>
string(2) "id"
}
["orphanRemoval"]=>
bool(false)
}
}
["isIdentifierComposite"]=>
bool(false)
["containsForeignIdentifier"]=>
bool(false)
["idGenerator"]=>
NULL
["sequenceGeneratorDefinition"]=>
NULL
["tableGeneratorDefinition"]=>
NULL
["changeTrackingPolicy"]=>
int(1)
["isVersioned"]=>
NULL
["versionField"]=>
NULL
["reflClass"]=>
NULL
["isReadOnly"]=>
bool(false)
["namingStrategy":protected]=>
object(Doctrine\ORM\Mapping\DefaultNamingStrategy)#258 (0) {
}
["reflFields"]=>
array(0) {
}
["_prototype":"Doctrine\ORM\Mapping\ClassMetadataInfo":private]=>
NULL
}
object(Doctrine\ORM\Mapping\ClassMetadata)#476 (36) {
["name"]=>
string(14) "RecipeCategory"
["namespace"]=>
string(0) ""
["rootEntityName"]=>
string(14) "RecipeCategory"
["customGeneratorDefinition"]=>
NULL
["customRepositoryClassName"]=>
NULL
["isMappedSuperclass"]=>
bool(false)
["parentClasses"]=>
array(0) {
}
["subClasses"]=>
array(0) {
}
["namedQueries"]=>
array(0) {
}
["namedNativeQueries"]=>
array(0) {
}
["sqlResultSetMappings"]=>
array(0) {
}
["identifier"]=>
array(1) {
[0]=>
string(2) "id"
}
["inheritanceType"]=>
int(1)
["generatorType"]=>
int(1)
["fieldMappings"]=>
array(3) {
["id"]=>
array(6) {
["id"]=>
bool(true)
["fieldName"]=>
string(2) "id"
["columnName"]=>
string(2) "id"
["type"]=>
string(7) "integer"
["unsigned"]=>
bool(false)
["nullable"]=>
bool(false)
}
["name"]=>
array(6) {
["fieldName"]=>
string(4) "name"
["columnName"]=>
string(4) "name"
["type"]=>
string(6) "string"
["length"]=>
int(45)
["fixed"]=>
bool(false)
["nullable"]=>
bool(false)
}
["description"]=>
array(6) {
["fieldName"]=>
string(11) "description"
["columnName"]=>
string(11) "description"
["type"]=>
string(6) "string"
["length"]=>
int(45)
["fixed"]=>
bool(false)
["nullable"]=>
bool(true)
}
}
["fieldNames"]=>
array(3) {
["id"]=>
string(2) "id"
["name"]=>
string(4) "name"
["description"]=>
string(11) "description"
}
["columnNames"]=>
array(3) {
["id"]=>
string(2) "id"
["name"]=>
string(4) "name"
["description"]=>
string(11) "description"
}
["discriminatorValue"]=>
NULL
["discriminatorMap"]=>
array(0) {
}
["discriminatorColumn"]=>
NULL
["table"]=>
array(1) {
["name"]=>
string(15) "recipe_category"
}
["lifecycleCallbacks"]=>
array(0) {
}
["associationMappings"]=>
array(2) {
["recipe"]=>
array(19) {
["fieldName"]=>
string(6) "recipe"
["targetEntity"]=>
string(6) "Recipe"
["inversedBy"]=>
string(14) "recipeCategory"
["joinTable"]=>
array(3) {
["name"]=>
string(22) "recipe*category*recipe"
["joinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(18) "recipe*category*id"
["referencedColumnName"]=>
string(2) "id"
}
}
["inverseJoinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(9) "recipe_id"
["referencedColumnName"]=>
string(9) "recipe_id"
}
}
}
["type"]=>
int(8)
["mappedBy"]=>
NULL
["isOwningSide"]=>
bool(true)
["sourceEntity"]=>
string(14) "RecipeCategory"
["fetch"]=>
int(2)
["cascade"]=>
array(0) {
}
["isCascadeRemove"]=>
bool(false)
["isCascadePersist"]=>
bool(false)
["isCascadeRefresh"]=>
bool(false)
["isCascadeMerge"]=>
bool(false)
["isCascadeDetach"]=>
bool(false)
["joinTableColumns"]=>
array(2) {
[0]=>
string(18) "recipe*category*id"
[1]=>
string(9) "recipe_id"
}
["relationToSourceKeyColumns"]=>
array(1) {
["recipe*category*id"]=>
string(2) "id"
}
["relationToTargetKeyColumns"]=>
array(1) {
["recipe_id"]=>
string(9) "recipe_id"
}
["orphanRemoval"]=>
bool(false)
}
["parent"]=>
array(19) {
["fieldName"]=>
string(6) "parent"
["targetEntity"]=>
string(14) "RecipeCategory"
["joinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(9) "parent_id"
["referencedColumnName"]=>
string(2) "id"
}
}
["type"]=>
int(2)
["mappedBy"]=>
NULL
["inversedBy"]=>
NULL
["isOwningSide"]=>
bool(true)
["sourceEntity"]=>
string(14) "RecipeCategory"
["fetch"]=>
int(2)
["cascade"]=>
array(0) {
}
["isCascadeRemove"]=>
bool(false)
["isCascadePersist"]=>
bool(false)
["isCascadeRefresh"]=>
bool(false)
["isCascadeMerge"]=>
bool(false)
["isCascadeDetach"]=>
bool(false)
["sourceToTargetKeyColumns"]=>
array(1) {
["parent_id"]=>
string(2) "id"
}
["joinColumnFieldNames"]=>
array(1) {
["parent_id"]=>
string(9) "parent_id"
}
["targetToSourceKeyColumns"]=>
array(1) {
["id"]=>
string(9) "parent_id"
}
["orphanRemoval"]=>
bool(false)
}
}
["isIdentifierComposite"]=>
bool(false)
["containsForeignIdentifier"]=>
bool(false)
["idGenerator"]=>
NULL
["sequenceGeneratorDefinition"]=>
NULL
["tableGeneratorDefinition"]=>
NULL
["changeTrackingPolicy"]=>
int(1)
["isVersioned"]=>
NULL
["versionField"]=>
NULL
["reflClass"]=>
NULL
["isReadOnly"]=>
bool(false)
["namingStrategy":protected]=>
object(Doctrine\ORM\Mapping\DefaultNamingStrategy)#258 (0) {
}
["reflFields"]=>
array(0) {
}
["_prototype":"Doctrine\ORM\Mapping\ClassMetadataInfo":private]=>
NULL
}
object(Doctrine\ORM\Mapping\ClassMetadata)#478 (36) {
["name"]=>
string(4) "Step"
["namespace"]=>
string(0) ""
["rootEntityName"]=>
string(4) "Step"
["customGeneratorDefinition"]=>
NULL
["customRepositoryClassName"]=>
NULL
["isMappedSuperclass"]=>
bool(false)
["parentClasses"]=>
array(0) {
}
["subClasses"]=>
array(0) {
}
["namedQueries"]=>
array(0) {
}
["namedNativeQueries"]=>
array(0) {
}
["sqlResultSetMappings"]=>
array(0) {
}
["identifier"]=>
array(2) {
[0]=>
string(10) "stepNumber"
[1]=>
string(6) "recipe"
}
["inheritanceType"]=>
int(1)
["generatorType"]=>
int(1)
["fieldMappings"]=>
array(4) {
["stepNumber"]=>
array(6) {
["id"]=>
bool(true)
["fieldName"]=>
string(10) "stepNumber"
["columnName"]=>
string(11) "step_number"
["type"]=>
string(7) "integer"
["unsigned"]=>
bool(false)
["nullable"]=>
bool(false)
}
["description"]=>
array(4) {
["fieldName"]=>
string(11) "description"
["columnName"]=>
string(11) "description"
["type"]=>
string(4) "text"
["nullable"]=>
bool(true)
}
["timer"]=>
array(5) {
["fieldName"]=>
string(5) "timer"
["columnName"]=>
string(5) "timer"
["type"]=>
string(7) "integer"
["unsigned"]=>
bool(false)
["nullable"]=>
bool(true)
}
["image"]=>
array(6) {
["fieldName"]=>
string(5) "image"
["columnName"]=>
string(5) "image"
["type"]=>
string(6) "string"
["length"]=>
int(100)
["fixed"]=>
bool(false)
["nullable"]=>
bool(true)
}
}
["fieldNames"]=>
array(4) {
["step_number"]=>
string(10) "stepNumber"
["description"]=>
string(11) "description"
["timer"]=>
string(5) "timer"
["image"]=>
string(5) "image"
}
["columnNames"]=>
array(4) {
["stepNumber"]=>
string(11) "step_number"
["description"]=>
string(11) "description"
["timer"]=>
string(5) "timer"
["image"]=>
string(5) "image"
}
["discriminatorValue"]=>
NULL
["discriminatorMap"]=>
array(0) {
}
["discriminatorColumn"]=>
NULL
["table"]=>
array(1) {
["name"]=>
string(4) "step"
}
["lifecycleCallbacks"]=>
array(0) {
}
["associationMappings"]=>
array(1) {
["recipe"]=>
array(20) {
["fieldName"]=>
string(6) "recipe"
["targetEntity"]=>
string(6) "Recipe"
["id"]=>
bool(true)
["joinColumns"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(9) "recipe_id"
["referencedColumnName"]=>
string(9) "recipe_id"
}
}
["type"]=>
int(1)
["mappedBy"]=>
NULL
["inversedBy"]=>
NULL
["isOwningSide"]=>
bool(true)
["sourceEntity"]=>
string(4) "Step"
["fetch"]=>
int(2)
["cascade"]=>
array(0) {
}
["isCascadeRemove"]=>
bool(false)
["isCascadePersist"]=>
bool(false)
["isCascadeRefresh"]=>
bool(false)
["isCascadeMerge"]=>
bool(false)
["isCascadeDetach"]=>
bool(false)
["sourceToTargetKeyColumns"]=>
array(1) {
["recipe_id"]=>
string(9) "recipe_id"
}
["joinColumnFieldNames"]=>
array(1) {
["recipe_id"]=>
string(9) "recipe_id"
}
["targetToSourceKeyColumns"]=>
array(1) {
["recipe_id"]=>
string(9) "recipe_id"
}
["orphanRemoval"]=>
bool(false)
}
}
["isIdentifierComposite"]=>
bool(true)
["containsForeignIdentifier"]=>
bool(true)
["idGenerator"]=>
NULL
["sequenceGeneratorDefinition"]=>
NULL
["tableGeneratorDefinition"]=>
NULL
["changeTrackingPolicy"]=>
int(1)
["isVersioned"]=>
NULL
["versionField"]=>
NULL
["reflClass"]=>
NULL
["isReadOnly"]=>
bool(false)
["namingStrategy":protected]=>
object(Doctrine\ORM\Mapping\DefaultNamingStrategy)#258 (0) {
}
["reflFields"]=>
array(0) {
}
["_prototype":"Doctrine\ORM\Mapping\ClassMetadataInfo":private]=>
NULL
}

@doctrinebot

Comment created by @beberlei:

Fixed and merged back to 2.3

@doctrinebot

Comment created by succinct:

I tested this again using 2.3.4 (the version which contains this fix) and it is still occurring. Attempting to import mapping for a table with 2 foreign keys in the primary key results in the error "Database does not have any mapping information." Adding a third column on the primary key "fixes" the issue.

Currently our developers are being asked to add a fake third part to the key to work around the issue, then delete that key once they get into the entity class. This is a bit tedious and I'd love to see a fix!

@doctrinebot

Comment created by succinct:

Issue still present in 2.3.4 and 2.4.0-RC1

@doctrinebot

Comment created by guillermoespinoza:

The database engine I use is PostgreSQL. I'm having problems when mapping entities with composite primary keys in other tables.

```CREATE TABLE public.establecimiento
(
  id_establecimiento integer NOT NULL,
  establecimiento character varying(100) NOT NULL,
  CONSTRAINT pk*establecimiento PRIMARY KEY (id*establecimiento )
)
WITH (
  OIDS=FALSE
);
CREATE TABLE public.establecimiento_sec
(
  id*establecimiento*sec integer NOT NULL,
  id_establecimiento integer NOT NULL,
  det_seccion character varying(40) NOT NULL,
  plano character varying(100),
  sector_ingreso character varying(254),
  sponsor*imagen*sec character varying(96000),
  CONSTRAINT pk*establecimientos_sec PRIMARY KEY (id_establecimiento_sec , id*establecimiento ),
  CONSTRAINT fk*establec_reference_establec FOREIGN KEY (id*establecimiento)
      REFERENCES public.establecimiento (id_establecimiento) MATCH SIMPLE
      ON UPDATE RESTRICT ON DELETE RESTRICT
)
WITH (
  OIDS=TRUE
);
CREATE TABLE public.establecimiento*sec*plano
(
  id*establecimiento_sec*plano integer NOT NULL,
  id*establecimiento*sec integer NOT NULL,
  id_establecimiento integer NOT NULL,
  det_plano character varying(512),
  cantidad integer NOT NULL,
  precio double precision,
  insert_charge double precision DEFAULT 0,
  descr character varying(254),
  CONSTRAINT pk*establecimiento_sec_plano PRIMARY KEY (id_establecimiento_sec_plano , id_establecimiento_sec , id*establecimiento ),
  CONSTRAINT fk*establecimiento_sec FOREIGN KEY (id_establecimiento, id_establecimiento*sec)
      REFERENCES public.establecimiento*sec (id_establecimiento, id_establecimiento*sec) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE CASCADE
)
WITH (
  OIDS=FALSE
);```

Defining the entity establecimientoSecPlano, $establecimientoSec variable containing the keys $establecimiento and $idestablecimientosec

//Entity/EstablecimientosSecPlano

```/****
 * @ORM\Id
 * @ORM\ManyToOne(targetEntity="Ticketway\PruebaBundle\Entity\EstablecimientosSec")
 * @ORM\JoinColumns(
 *      @ORM\JoinColumn(name="id*establecimiento_sec", referencedColumnName="id_establecimiento*sec"),
 *      @ORM\JoinColumn(name="id*establecimiento", referencedColumnName="id*establecimiento")) 
 */
private $establecimientoSec;```

//Entity/EstablecimientosSec

 ```/****
 * @ORM\Id
 * @ORM\ManyToOne(targetEntity="Ticketway\PruebaBundle\Entity\Establecimientos")
 * @ORM\JoinColumn(name="id*establecimiento", referencedColumnName="id*establecimiento") 
 */
private $establecimiento;```

When executing the command doctrine: mapping: import I get the following error

[Doctrine\ORM\Mapping\MappingException]
It is not possible to map entity 'EstablecimientoSec' with a composite primary key as part of the
primary key of another entity 'EstablecimientoSecPlano#idEstablecimiento'.

@doctrinebot

Comment created by samvdb:

We are having the same problem as Guillermo. Any idea on how to fix this issue?
Does anybody know why this problem occurs? I have been looking in the code but havent had much success.

@doctrinebot

Comment created by diegotdai:

Doesn't work for me either, composite keys aren't working in 2.3.4

Can we get a fix for this?

@doctrinebot

Comment created by kamil:

I have similar issue in my current project. Is there any chance to solve this problem in the near future?
Composite primary/foreign keys are important...

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.3.4 milestone
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.