Wrong error reporting on multiple GeneratedValue annotation usage #6819

Closed
opened 2026-01-22 15:39:26 +01:00 by admin · 2 comments
Owner

Originally created by @Genarito on GitHub (Sep 6, 2021).

Hello, I don't know if the issue is still present in the current versions of Doctrine. The version I'm using is doctrine/orm": "2.3.x-dev and, as I describe in this Stack Overflow question when GeneratedValue is used on multiple fields with different strategies Doctrines uses only the last definition. For instance, defining:

/**
 * @var integer
 *
 * @ORM\Column(name="CONTRACT", type="integer", nullable=false)
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="SEQUENCE")
 * @ORM\SequenceGenerator(sequenceName="SID_CONTRACT", allocationSize=1, initialValue=1)
 */
private $contract;

/**
 * @var string
 *
 * @ORM\Column(name="TYPE", type="string", length=1, nullable=false)
 * @ORM\GeneratedValue(strategy="NONE")  // This was the conflicting line
 */
private $type;

Will wire the Doctrine\ORM\Id\AssignedGenerator to the field contract instead of Doctrine\ORM\Id\SequenceGenerator. More detailed information in my S.O. question.

Maybe it'll be great to improve the documentation to describe this behavior or fix it if it's not expected.

Thanks!

Originally created by @Genarito on GitHub (Sep 6, 2021). Hello, I don't know if the issue is still present in the current versions of Doctrine. The version I'm using is `doctrine/orm": "2.3.x-dev` and, as I describe in [this Stack Overflow question](https://stackoverflow.com/q/69036275/7058363) when `GeneratedValue` is used on multiple fields with different strategies Doctrines uses only the last definition. For instance, defining: ```php /** * @var integer * * @ORM\Column(name="CONTRACT", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="SEQUENCE") * @ORM\SequenceGenerator(sequenceName="SID_CONTRACT", allocationSize=1, initialValue=1) */ private $contract; /** * @var string * * @ORM\Column(name="TYPE", type="string", length=1, nullable=false) * @ORM\GeneratedValue(strategy="NONE") // This was the conflicting line */ private $type; ``` Will wire the `Doctrine\ORM\Id\AssignedGenerator` to the field `contract` instead of `Doctrine\ORM\Id\SequenceGenerator`. **More detailed information in my S.O. question**. Maybe it'll be great to improve the documentation to describe this behavior or fix it if it's not expected. Thanks!
admin closed this issue 2026-01-22 15:39:27 +01:00
Author
Owner

@greg0ire commented on GitHub (Sep 8, 2021):

The version I'm using is doctrine/orm": "2.3.x-dev"

Why are you not using a stable version? That area of the code has been touched lately, so it's quite important to determine which version you are actually using with composer show|grep orm. Also, did you suddenly experience this issue after an upgrade?

@greg0ire commented on GitHub (Sep 8, 2021): > The version I'm using is `doctrine/orm": "2.3.x-dev"` Why are you not using a stable version? That area of the code has been touched lately, so it's quite important to determine which version you are actually using with `composer show|grep orm`. Also, did you suddenly experience this issue after an upgrade?
Author
Owner

@derrabus commented on GitHub (Sep 9, 2021):

Let's move this to support. I don't think that an issue with a more than seven years old dev snapshot counts as a bug report. 🙂

@derrabus commented on GitHub (Sep 9, 2021): Let's move this to support. I don't think that an issue with a more than seven years old dev snapshot counts as a bug report. 🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6819