I am looking for some information / documentation, which helps me to grasp why in the Inherited-case a (ManyToOne or OneToOne) join is not done using the storage name but using the property name of the corresponding entity object class ... can somebody please explain me the underlying mechanism?
The special case I am refering to is, when the joining field is not a foreign key. Particular I am refering to this code section:
ManyToOneJoinBuilder.php, line 57
When there is no foreign key involved, the join will occur using the propertyName, but obviously this must not be the same as the storageName ... and generates an error ... when the resulting sql gets executed!
There need to be extra fields in the DB table, where the foreign keys are saved in a read optimized manner. The convention here is to use the property name as the column name.
From the docs
For every inherited field you have to add a binary column to the entity, which is used for saving the inherited information in a read optimized manner
If you take a look at the columns of the product
you'll find columns named manufacturer
, tax
or deliveryTime
. These are the columns where the FK get's stored that's used to join the matching association.
This is necessary for the data abstraction layer, so it can join the associated tables without needing to read the row of the parent entity. This greatly improves the performance as you can join multiple association in one SQL query and the DB can optimize on that query. Otherwise you would need to do a read on the entity and the parent entity first, just to figure out if some associations are inherited from the parent to the child and on which FK to perform the join.
This is shortly described at this section of the docs.
I hope this answers your question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With