Details
Description
When using a sequence in Oracle as part of a composite key and the sequence is defined second, Doctrine retrieves from the sequence correctly but incorrectly assigns to the first key (which in this case is not the correct column)
Example:
/Entity/ItemModel.php
/** * @Column(name="submission_id", type="integer") * @Id */ private $submissionId; /** * @Column(name="model_id", type="integer") * @Id * @GeneratedValue(strategy="AUTO") * @SequenceGenerator(sequenceName="model_id_seq", initialValue=1, allocationSize=1) */ private $modelId;
Doctrine correctly retrieves the sequence, however it then attempts to set the first identifier field (in this case submission_id) instead of the sequence key.
The problem appears in /Doctrine/ORM/UnitOfWork.php line 613.
$class->indentifier is hard coded to item 0.
$this->entityIdentifiers[$oid] = array($class->identifier[0] => $idValue);
You can workaround this issue by defining the sequence first in the entity.
This is not allowed currently, there is a PR for custom id generators, but so long i am closing this as invalid.
Also i added an error exception which makes this kind of setup fail.