Minor formatting improvements
Numbered lists aren't displayed nicely, see e.g. http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#persistence-by-reachability-cascade-persist - is this a rendering bug?
This commit is contained in:
parent
63e4eea9e2
commit
38636e7db4
@ -424,7 +424,7 @@ comment might look like in your controller (without ``cascade: persist``):
|
|||||||
$user->addComment($myFirstComment);
|
$user->addComment($myFirstComment);
|
||||||
|
|
||||||
$em->persist($user);
|
$em->persist($user);
|
||||||
$em->persist($myFirstComment); // required, if `cascade: persist` isn't set
|
$em->persist($myFirstComment); // required, if `cascade: persist` is not set
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
Note that the Comment entity is instantiated right here in the controller.
|
Note that the Comment entity is instantiated right here in the controller.
|
||||||
@ -504,15 +504,15 @@ Thanks to ``cascade: remove``, you can easily delete a user and all linked comme
|
|||||||
|
|
||||||
Cascade operations are performed in memory. That means collections and related entities
|
Cascade operations are performed in memory. That means collections and related entities
|
||||||
are fetched into memory (even if they are marked as lazy) when
|
are fetched into memory (even if they are marked as lazy) when
|
||||||
the cascade operation is about to be performed. However this approach allows
|
the cascade operation is about to be performed. This approach allows
|
||||||
entity lifecycle events to be performed for each of these operations.
|
entity lifecycle events to be performed for each of these operations.
|
||||||
|
|
||||||
However, pulling objects graph into memory on cascade can cause considerable performance
|
However, pulling object graphs into memory on cascade can cause considerable performance
|
||||||
overhead, especially when the cascaded collections are large. Make sure
|
overhead, especially when the cascaded collections are large. Make sure
|
||||||
to weigh the benefits and downsides of each cascade operation that you define.
|
to weigh the benefits and downsides of each cascade operation that you define.
|
||||||
|
|
||||||
To rely on the database level cascade operations for the delete operation instead, you can
|
To rely on the database level cascade operations for the delete operation instead, you can
|
||||||
configure each join column with :doc:`the **onDelete** option <working-with-objects>`.
|
configure each join column with :doc:`the onDelete option <working-with-objects>`.
|
||||||
|
|
||||||
Even though automatic cascading is convenient, it should be used
|
Even though automatic cascading is convenient, it should be used
|
||||||
with care. Do not blindly apply ``cascade=all`` to all associations as
|
with care. Do not blindly apply ``cascade=all`` to all associations as
|
||||||
@ -525,21 +525,20 @@ Persistence by Reachability: Cascade Persist
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
There are additional semantics that apply to the Cascade Persist
|
There are additional semantics that apply to the Cascade Persist
|
||||||
operation. During each flush() operation Doctrine detects if there
|
operation. During each ``flush()`` operation Doctrine detects if there
|
||||||
are new entities in any collection and three possible cases can
|
are new entities in any collection and three possible cases can
|
||||||
happen:
|
happen:
|
||||||
|
|
||||||
|
|
||||||
1. New entities in a collection marked as cascade persist will be
|
1. New entities in a collection marked as ``cascade: persist`` will be
|
||||||
directly persisted by Doctrine.
|
directly persisted by Doctrine.
|
||||||
2. New entities in a collection not marked as cascade persist will
|
2. New entities in a collection not marked as ``cascade: persist`` will
|
||||||
produce an Exception and rollback the flush() operation.
|
produce an Exception and rollback the ``flush()`` operation.
|
||||||
3. Collections without new entities are skipped.
|
3. Collections without new entities are skipped.
|
||||||
|
|
||||||
This concept is called Persistence by Reachability: New entities
|
This concept is called Persistence by Reachability: New entities
|
||||||
that are found on already managed entities are automatically
|
that are found on already managed entities are automatically
|
||||||
persisted as long as the association is defined as cascade
|
persisted as long as the association is defined as ``cascade: persist``.
|
||||||
persist.
|
|
||||||
|
|
||||||
Orphan Removal
|
Orphan Removal
|
||||||
--------------
|
--------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user