Skip to content


DDC-1456: Sequence doesn't work correctly when sequence is defined second in a composite key #2084

doctrinebot opened this Issue · 2 comments

2 participants


Jira issue originally created by user zorfling:

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)


 * @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.


Comment created by @beberlei:

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.


Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.2 milestone
@doctrinebot doctrinebot closed this
@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.