The error occurring because you're trying to create a new object with the
same id.
You need to find the object with $object =  find() and set the attributes
on this object $object->set...(...). Then persist and flush.



2014-06-03 16:44 GMT-03:00 Nima Sadjadi <[email protected]>:

> It means I need to have the line below, in catch clause before
> trigger_error?
> $em = EntityManager::create($dbParams, $config, $evm);
>
>
>
> On Tue, Jun 3, 2014 at 11:41 PM, Marco Pivetta <[email protected]> wrote:
>
>> You need a new entity manager. The EntityManager is being closed because
>> its internal state (transaction and UnitOfWork) may be broken due to an
>> error.
>>
>> Marco Pivetta
>>
>> http://twitter.com/Ocramius
>>
>> http://ocramius.github.com/
>>
>>
>> On 3 June 2014 21:09, Nima Sadjadi <[email protected]> wrote:
>>
>>>
>>> I discovered the problem, I see when an exception occurs, the
>>> entitymanager will be closed. the error I was getting was because of:
>>> trigger_error($e->getMessage(), E_USER_ERROR);
>>> in my error handler, I was attempting to log $e->getMessage() into
>>> database but entity manager was closed because of the occured exception
>>> priorly in my controller. How can I fix this and restart the entity manager
>>> that is closed because of an exception?
>>>
>>>
>>>
>>> On Tue, Jun 3, 2014 at 5:46 PM, Nima Sadjadi <[email protected]> wrote:
>>>
>>>> Product and Info entities are OneToOne. Info is the owning side.
>>>> I did this to add a new Info:
>>>>
>>>>                  $product = $em->find('Entities\Product',
>>>> $_POST['productId']);
>>>>                   if ($product !== null) {
>>>>                       try {
>>>>                            $info = new Entities\Info;
>>>>                            $info->setProduct($product);
>>>>                            $info->setFields($_POST, array('...'));
>>>>                            $em->persist($info);
>>>>                            $em->flush();
>>>>                       } catch (Exception $e) {
>>>>                            trigger_error($e->getMessage(),
>>>> E_USER_ERROR);
>>>>                       }
>>>>                  }
>>>>
>>>> when I added a another Info for the same product, of course I was
>>>> getting duplicate entry exception (because there are OneToOne) and
>>>> try/catch was working fine too. But when I did run orm:update and FK
>>>> indices are added into db, instead of duplicate entry error, I am getting
>>>> "Entity is Closed" exception and try/catch is no longer catching it and the
>>>> script terminates for exception, I tried to debug it and noticed if I
>>>> remove persist line I don't get exception any more and nothing flushed of
>>>> course. I am trying to fix it by searching google and wiki but no success
>>>> yet after 1 week! stuck on this! please help. I appreciate it.
>>>>
>>>>
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "doctrine-user" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/doctrine-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Rodrigo Wanderley de Melo Cardoso
PHP Web Developer - Bacharel em Matemática Aplicada e Computacional - UFRRJ
Estudante MBA - Engenharia de Softwares Orientada para Serviços - Veris
IBTA Metrocamp
Facebook <http://www.facebook.com/pokemaobr> LinkedIn
<http://www.linkedin.com/in/rwdmc> Twitter
<http://www.twitter.com/pokemaobr>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to