1
0
Fork 0
mirror of synced 2025-04-01 12:26:11 +03:00

DDC-1456 - Disallow setting id generators on composite identifiers.

This commit is contained in:
Benjamin Eberlei 2011-12-18 00:32:35 +01:00
parent 072094f722
commit 9cd8f85a8c
3 changed files with 10 additions and 3 deletions

View file

@ -371,6 +371,10 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
// second condition is necessary for mapped superclasses in the middle of an inheritance hierachy
throw MappingException::noInheritanceOnMappedSuperClass($class->name);
}
if ($class->usesIdGenerator() && $class->isIdentifierComposite) {
throw MappingException::compositeKeyAssignedIdGeneratorRequired($class->name);
}
}
/**

View file

@ -314,4 +314,9 @@ class MappingException extends \Doctrine\ORM\ORMException
{
return new self("Entity '" . $className . "' has a mapping with invalid fetch mode '" . $annotation . "'");
}
public static function compositeKeyAssignedIdGeneratorRequired($className)
{
return new self("Entity '". $className . "' has a composite identifier but uses an ID generator other than manually assigning (Identity, Sequence). This is not supported.");
}
}

View file

@ -141,13 +141,11 @@ class InvalidEntity2
{
/**
* @Id @Column
* @GeneratedValue(strategy="AUTO")
*/
protected $key3;
/**
* @Id @Column
* @GeneratedValue(strategy="AUTO")
*/
protected $key4;
@ -155,4 +153,4 @@ class InvalidEntity2
* @ManyToOne(targetEntity="InvalidEntity1")
*/
protected $assoc;
}
}