DDC-822: Query with detached Entity as parameter fails to execute #1012

Open
opened 2026-01-22 12:58:53 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 30, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user nicokaiser:

When dealing with detached entities, e.g. with the QueryCache, you cannot use these entities as parameters for other Query.

Example:

$em->detach($user);
$query = $em->createQuery('SELECT a FROM Address a WHERE a.User = ?1');
$query->setParameter(1, $user); // $user is detached

As $user is detached, the EntityManager does not have its identifier, so Query::_doExecute fails. (There is a "//TODO: Check that $value is MANAGED?" line near the failing line).

Originally created by @doctrinebot on GitHub (Sep 30, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user nicokaiser: When dealing with detached entities, e.g. with the QueryCache, you cannot use these entities as parameters for other Query. Example: ``` php $em->detach($user); $query = $em->createQuery('SELECT a FROM Address a WHERE a.User = ?1'); $query->setParameter(1, $user); // $user is detached ``` As $user is detached, the EntityManager does not have its identifier, so Query::_doExecute fails. (There is a "//TODO: Check that $value is MANAGED?" line near the failing line).
admin added the Bug label 2026-01-22 12:58:53 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1012