DDC-1456 - Disallow setting id generators on composite identifiers.
This commit is contained in:
parent
072094f722
commit
9cd8f85a8c
3 changed files with 10 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue