Member-only story
You need to stop updating your Entities in Symfony and start using the Query Builder. Here’s why.

Today, I want to tell you about a real-world problem I encountered some years ago. Due to the Non-Disclosure Agreement I signed, I won’t mention if this was a problem working for an agency or a product company, but it could affect both.
You can follow up on the “Race Condition” problem I exposed in this article by reading the next one.
One of the most convenient practices when working with Symfony (or any other framework; let’s face this reality) is the ability to auto-inject a specific Entity into your Controller.
This is achieved by mapping its primary ID/UUID field into your URLs, a feature that greatly simplifies your coding process.
// src/Controller/BlogPostController.php
namespace App\Controller;
use App\Entity\BlogPost;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Attribute\Route;
class BlogPostController extends AbstractController
{
#[Route(path: '/blog/post/{uuid}', methods: ['GET'])]
public function __invoke(
BlogPost $blogPost,
): Response {
// ...
}
}
While using this approach to retrieve an existing Entity from the Repository can be very handy, it’s important to note that it’s also…