[DDC-687] Add New Entity Attribute "idGetter" to allow accessing the ID without triggering lazy-load Created: 12/Jul/10 Updated: 11/Sep/13 Resolved: 11/Sep/13
|Project:||Doctrine 2 - ORM|
|Reporter:||Benjamin Eberlei||Assignee:||Roman S. Borschel|
Often people present us with the use-case that they want to access the ID of a proxy without loading it.
This has lead to several ugly solutions like mapping the ID to an object and as a foreign key field. There currently exists a simple solution for this:
However we could add a new property here called "idGetter" that would take the name of a method.
During Proxy Generation then this method is created with magic functionality that:
1. In case of Single Primary Key returns the single value
|Comment by Stefan Klug [ 25/Jan/11 ]|
What about an @IdGetter annotation. A function instrumented like this would not trigger the lazy load within the proxy.
would then result in the proxy implementation
After reading the original post I realized that it proposed nearly the same thing. Nevertheless I'll leave it here for clarity. I still think that an annotation on a function would be better, than an annotation which gets the function name as a parameter.
|Comment by Benjamin Eberlei [ 25/Jan/11 ]|
$this->_identifier is an array.
|Comment by Benjamin Eberlei [ 11/Sep/13 ]|
This was implemented in 2.2 by detecting when this can be done on a getId() call automatically.