Details
-
Type:
New Feature
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0-ALPHA3
-
Fix Version/s: 2.1
-
Component/s: None
-
Security Level: All
-
Labels:None
Description
Sometimes, a @ManyToOne field has to be the Primary Key, or part of the Primary Key. Adding @Id to the @ManyToOne does not help, an additional property with duplicates the referenced id is needed:
(userId and User field in the Phonenumber class - to be able to set @Id on userId):
http://pastebin.com/d51e021e2
Allowing @Id on @ManyToOne fields (which would make the JoinColumn a PK) would help here. Any maybe this would also fix DDC-116
Issue Links
- is duplicated by
-
DDC-795
Wrong SQL statement when using loadOneToManyCollection
-
Activity
Roman S. Borschel
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 2.1 [ 10022 ] | |
| Affects Version/s | 2.0-ALPHA3 [ 10029 ] |
Benjamin Eberlei
made changes -
| Assignee | Roman S. Borschel [ romanb ] | Benjamin Eberlei [ beberlei ] |
s9e
made changes -
| Attachment | DDC117-2Test.php [ 10728 ] |
Benjamin Eberlei
made changes -
| Status | Open [ 1 ] | In Progress [ 3 ] |
Benjamin Eberlei
made changes -
| Attachment | DDC117-2Test.php [ 10728 ] |
Benjamin Eberlei
made changes -
| Attachment | ddc117_20100815.patch [ 10741 ] |
s9e
made changes -
| Attachment | ddc117test_cascade_persist.patch [ 10742 ] |
Benjamin Eberlei
made changes -
Benjamin Eberlei
made changes -
| Attachment | ddc117-20101228.diff [ 10902 ] |
Benjamin Eberlei
made changes -
| Status | In Progress [ 3 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
Benjamin Eberlei
made changes -
| Workflow | jira [ 10344 ] | jira-feedback [ 14157 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback [ 14157 ] | jira-feedback2 [ 16021 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 16021 ] | jira-feedback3 [ 18274 ] |
This list may be incomplete, as errors occurred whilst retrieving source from linked applications:
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-117, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
Thanks for your reply on doctrine-user!
My previous workaround was something like this:
http://pastie.org/private/uoawwvf75onnvph8bj1fwg
Instead of just having a $User property in the Phonenumber entity (which is mapped by the userId field in the phonenumber table), I have an additional $userId property, which is also mapped to the userId DB field. This way I could make $userId @Id (and thus add it to the PKs), but I had to manually update it when I set the $User (see the TODO annotations in the Pastie code).
I see "EntityManager#find(...)" would have to be able to also get objects as identifiers, e.g. (int, User), which may have major implications...
However I think to support constructions like this is very important as it's a very common pattern, especially for OneToOne associations with no additional identifier field (PK = FK)...