mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Delete doctrine entity with multiple ID properties and relation #6916
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TomAMarine on GitHub (Jan 27, 2022).
Hi,
I have a problem in the configuration of Doctrine.
I have two PHP classes described below. A class that represents a boat model "Model" and another that represents an alias "ModelAlias". Example: "ANTARES 6 FISHING" is an alias of "ANTARES 6". These two names correspond to the same boat.
A model can have 0 or more aliases.
The unique key of my "ModelAlias" entity is a combination of the model id and the alias name.
So, I added the annotation "@ORM\Id" on "model" and "name" properties. The property "model" is a relation to the "Model" entity.
Simplified class "Model"
Simplified Class "ModelAlias"
When I delete the alias with "remove" function Doctrine, I get an error message :
The DELETE request generated by Doctrine is :
But, the column name "model" is invalid. It should be "model_id" because I have this annotation "@ORM\JoinColumn(name="model_id")" on the "model" property.
Do you have an idea to fix my problem ?
Thank you for you help.
@wazum commented on GitHub (Mar 4, 2022):
I have the same (or a similar) thing here, maybe I'm doing something wrong, but I can't find the problem.
My Product entity
has many releases (with further associations)
whenever I try to remove releases from the product's collection, I get the error
unknown field "product", "market", "language".The Doctrine diff command created migrations with the correct field names
product_id, market_id, language_idhere.