Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Invalid
-
Affects Version/s: 2.1
-
Fix Version/s: None
-
Component/s: ORM
-
Security Level: All
-
Labels:None
-
Environment:Symfony 2.0.18
Description
I use a custom validation constraint.
In the constraint I want to compare old and new entity, but when I take a entity from database, I got a entity witch is equvivalent the new entity.
I tried to use a query without cache
$query = $this->getDoctrine()->getRepository('SSWTestBundle:SimpleEntity')->createNamedQuery(...);
...
$query->useResultCache(FALSE);
This don't solved my problem.
I tried to use a query without cache and with refresh
$query = $this->getDoctrine()->getRepository('SSWTestBundle:SimpleEntity')->createNamedQuery(...); ... $query->useResultCache(FALSE); $query->setHint(\Doctrine\ORM\Query::HINT_REFRESH, true);
This time I got a old entity from database, but the new entity was rollback to the old entity.
In attach is my entity and TestCase.
While I solved this problem so
I registered mine own hint.
I added folow code.
/** * SSW * @var string */ const HINT_CREATE_NEW_INSTANCE = 'doctrine.create.new.instance';And
I know it's wrong, because the new instanse overrided the old instance.