DDC-3753: ManyToMany Relations from Value objects #4606

Closed
opened 2026-01-22 14:45:51 +01:00 by admin · 8 comments
Owner

Originally created by @doctrinebot on GitHub (Jun 3, 2015).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user Ma27:

I was trying to setup a many-to-many and a one-to-one relation from an embeddable object, but doctrine ignores these relation columns/tables (see screenshots).
As you can see, I've created a relation for followers called SEN_Following and SEN_UserToRole, but when reviewing the tables on the mysql, these tables are not shown.

When executing "php app/console doctrine:schema:update" I get the following message:
Nothing to update - your database is already in sync with the current entity metadata.

Originally created by @doctrinebot on GitHub (Jun 3, 2015). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user Ma27: I was trying to setup a many-to-many and a one-to-one relation from an embeddable object, but doctrine ignores these relation columns/tables (see screenshots). As you can see, I've created a relation for followers called SEN_Following and SEN_UserToRole, but when reviewing the tables on the mysql, these tables are not shown. When executing "php app/console doctrine:schema:update" I get the following message: Nothing to update - your database is already in sync with the current entity metadata.
admin added the Bug label 2026-01-22 14:45:51 +01:00
admin closed this issue 2026-01-22 14:45:51 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2015):

Comment created by Ma27:

in order to review the whole code, I've pushed to a remote feature branch on github: https://github.com/Ma27/SenNetwork/tree/SenNetwork-108

@doctrinebot commented on GitHub (Jun 3, 2015): Comment created by Ma27: in order to review the whole code, I've pushed to a remote feature branch on github: https://github.com/Ma27/SenNetwork/tree/SenNetwork-108
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2015):

Comment created by @ocramius:

Value Objects should not reference entities in any case.

@doctrinebot commented on GitHub (Jun 3, 2015): Comment created by @ocramius: Value Objects should not reference entities in any case.
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2015):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jun 3, 2015): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2015):

Comment created by Ma27:

ok thanks.

but just out of interest: why shouldn't they do??

@doctrinebot commented on GitHub (Jun 3, 2015): Comment created by Ma27: ok thanks. but just out of interest: why shouldn't they do??
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2015):

Comment created by @ocramius:

[~Ma27] a value object can be compared with another value object by its value, whereas an entity is compared via identifier.

If you include an entity inside your VO you are comparing also the entity state (which is not comparable except for the identifier), and that breaks the entire idea of VO.

VOs should only reference other VOs and primitive types.

@doctrinebot commented on GitHub (Jun 3, 2015): Comment created by @ocramius: [~Ma27] a value object can be compared with another value object by its value, whereas an entity is compared via identifier. If you include an entity inside your VO you are comparing also the entity state (which is not comparable except for the identifier), and that breaks the entire idea of VO. VOs should only reference other VOs and primitive types.
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2015):

Comment created by Ma27:

[~Ocramius] thank you for your explanation.
but is there a way, how to persist collections inside a value objects??

serialization is IMHO a bad idea. For example I'd like to create a list which shows all users having a specific role, I had to load all users and the UserDetail object and check if they have the value object. With another table I could write a query for that.

@doctrinebot commented on GitHub (Jun 3, 2015): Comment created by Ma27: [~Ocramius] thank you for your explanation. but is there a way, how to persist collections inside a value objects?? serialization is IMHO a bad idea. For example I'd like to create a list which shows all users having a specific role, I had to load all users and the UserDetail object and check if they have the value object. With another table I could write a query for that.
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2015):

Comment created by @ocramius:

@doctrinebot commented on GitHub (Jun 3, 2015): Comment created by @ocramius:
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2015):

Comment created by Ma27:

[~ocramius] ok thank you for your help.

I think the simplest solution is moving these relations into the entity and waiting for that feature.
The problem I'll ran into with serialization is that it's virtually impossible to query against a serialized string

@doctrinebot commented on GitHub (Jun 3, 2015): Comment created by Ma27: [~ocramius] ok thank you for your help. I think the simplest solution is moving these relations into the entity and waiting for that feature. The problem I'll ran into with serialization is that it's virtually impossible to query against a serialized string
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4606