Does an ID always need to be mapped to a property? #6554

Closed
opened 2026-01-22 15:34:55 +01:00 by admin · 1 comment
Owner

Originally created by @gjdanis on GitHub (Oct 15, 2020).

Is mapping an ID to a property required? For example if I have:


/**
 * @Entity
 * @Table(name="tblUser")
 */
class User
{
    /**
     * @Id
     * @Column(name="ID", type="integer")
     * @Column(name="ID", type="integer", nullable=false)
     * @GeneratedValue
     */
    private ?int $id;

    ...

And I never expose this field, do I need to have it mapped as a property. Is it possible to not map this field to a property?

Originally created by @gjdanis on GitHub (Oct 15, 2020). Is mapping an ID to a property required? For example if I have: ```php /** * @Entity * @Table(name="tblUser") */ class User { /** * @Id * @Column(name="ID", type="integer") * @Column(name="ID", type="integer", nullable=false) * @GeneratedValue */ private ?int $id; ... ``` And I never expose this field, do I need to have it mapped as a property. Is it possible to not map this field to a property?
admin closed this issue 2026-01-22 15:34:55 +01:00
Author
Owner

@beberlei commented on GitHub (Oct 17, 2020):

No, its required to have the property.

@beberlei commented on GitHub (Oct 17, 2020): No, its required to have the property.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6554