Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Broken entities using detach, Doctrine APC cache driver, and merge
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nick Walke  
View profile  
 More options Nov 13 2012, 9:56 pm
From: Nick Walke <tubaguy50...@gmail.com>
Date: Tue, 13 Nov 2012 18:56:45 -0800 (PST)
Local: Tues, Nov 13 2012 9:56 pm
Subject: Broken entities using detach, Doctrine APC cache driver, and merge

I've posted my question on StackOverflow<http://stackoverflow.com/questions/13372305/doctrine-detaching-cachin...>,
but this is fairly urgent.  Please let me know if you can help.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac Henrique  
View profile  
 More options Nov 13 2012, 10:11 pm
From: Isaac Henrique <isaac.musa...@gmail.com>
Date: Wed, 14 Nov 2012 00:11:05 -0300
Local: Tues, Nov 13 2012 10:11 pm
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge

set to cascade={all} entity

2012/11/13 Nick Walke <tubaguy50...@gmail.com>

> I've posted my question on StackOverflow<http://stackoverflow.com/questions/13372305/doctrine-detaching-cachin...>,
> but this is fairly urgent.  Please let me know if you can help.

> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/doctrine-user/-/bvB5L9-bpXsJ.
> To post to this group, send email to doctrine-user@googlegroups.com.
> To unsubscribe from this group, send email to
> doctrine-user+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/doctrine-user?hl=en.

--
________________________________
       Isaac Henrique Barbosa Nunes
  Analista e Desenvolvedor de Sistema

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nick Walke  
View profile  
 More options Nov 13 2012, 10:11 pm
From: Nick Walke <tubaguy50...@gmail.com>
Date: Tue, 13 Nov 2012 19:11:59 -0800 (PST)
Local: Tues, Nov 13 2012 10:11 pm
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge

That won't introduce a second copy of the company entity in the database?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac Henrique  
View profile  
 More options Nov 13 2012, 10:13 pm
From: Isaac Henrique <isaac.musa...@gmail.com>
Date: Wed, 14 Nov 2012 00:13:28 -0300
Local: Tues, Nov 13 2012 10:13 pm
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge

not

2012/11/14 Nick Walke <tubaguy50...@gmail.com>

--
________________________________
       Isaac Henrique Barbosa Nunes
  Analista e Desenvolvedor de Sistema

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jasper N. Brouwer  
View profile  
 More options Nov 14 2012, 4:00 am
From: "Jasper N. Brouwer" <jas...@nerdsweide.nl>
Date: Wed, 14 Nov 2012 10:00:35 +0100
Local: Wed, Nov 14 2012 4:00 am
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge
http://stackoverflow.com/a/13375384/1237411

Be ware you don't put something like
    cascade={"persist"}
on $company in your ClientType entity, because that *will* insert a new Company into your db ;)

--
Jasper N. Brouwer

On 14-11-2012, at 03:56, Nick Walke <tubaguy50...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benjamin Eberlei  
View profile  
 More options Nov 14 2012, 5:32 am
From: Benjamin Eberlei <kont...@beberlei.de>
Date: Wed, 14 Nov 2012 11:32:43 +0100
Local: Wed, Nov 14 2012 5:32 am
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge

You have to be in sync with cascade merge and cascade detach. So if you
detach the User with Company, then they should also be merged together.
Because the company has an ID as well in the cache entry, this will not
create a new one.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nick Walke  
View profile  
 More options Nov 14 2012, 8:35 pm
From: Nick Walke <tubaguy50...@gmail.com>
Date: Wed, 14 Nov 2012 17:35:04 -0800 (PST)
Local: Wed, Nov 14 2012 8:35 pm
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge

Please see my update on Stackoverflow.  Your suggestion to me did not work.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jasper N. Brouwer  
View profile  
 More options Nov 15 2012, 2:37 am
From: "Jasper N. Brouwer" <jas...@nerdsweide.nl>
Date: Thu, 15 Nov 2012 08:36:58 +0100
Local: Thurs, Nov 15 2012 2:36 am
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge
Before I can give you a correct answer on StackOverfow, I think you'll have to debug some stuff:

It could be the problem is between:

    $entity = $cacheDriver->fetch($cacheId);
    $em->merge($entity);

and:

    $newEntitiy['company'] = $this->user['company'];

That last line kind of looks like you're grabbing the user from a session (logged in user). Could you try the following:

Just before that last line, insert:

    var_dump($em->contains($this->user));
    var_dump($em->contains($this->user['company']));

This is to check if the User and its Company entities are managed by (correctly merged into) the EntityManager.

If not, I imagine the following happening:
- When you log in to your application, and that user is in the cache, it gets fetched from the cache and merged into the EntityManger.
- The user is stored (serialised) in a session (to keep it logged in).
- In other requests the user is fetched (unserialised) from a session, but isn't merged into the EntityManager.

PS: Please let me know the results, even if this is the problem. I kind of need the points on StackOverflow in order to comment everywhere ;)

--
Jasper N. Brouwer

On 15-11-2012, at 02:35, Nick Walke <tubaguy50...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nick Walke  
View profile  
 More options Nov 15 2012, 3:00 am
From: Nick Walke <tubaguy50...@gmail.com>
Date: Thu, 15 Nov 2012 00:00:40 -0800 (PST)
Local: Thurs, Nov 15 2012 3:00 am
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge

They both return false.  The only thing I store in the session is the
user's ID.  I then take that ID and see if I can grab the entity from cache
(along with company and privilege).  The only thing I do before passing it
to the cache driver is "detach" on the result.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jasper N. Brouwer  
View profile  
 More options Nov 15 2012, 3:48 am
From: "Jasper N. Brouwer" <jas...@nerdsweide.nl>
Date: Thu, 15 Nov 2012 09:47:56 +0100
Local: Thurs, Nov 15 2012 3:47 am
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge

> They both return false.

Ok, this means that at the point where you are using the User and its Company, they're *not* managed by the EntityManager. This is why Doctrine gives you the "A new entity was found ... that was not configured to cascade persist operations for entity" exception.

> The only thing I store in the session is the user's ID.  I then take that ID and see if I can grab the entity from cache (along with company and privilege).  The only thing I do before passing it to the cache driver is "detach" on the result.

And I now see the flaw:

    $entity = $cacheDriver->fetch($cacheId);
    $em->merge($entity);
    return $entity;

This should be:

    $entity = $cacheDriver->fetch($cacheId);
    $entity = $em->merge($entity);
    return $entity;

The thing with merge() is that it leaves the entity you pass as argument untouched, and returns a *new* object that represents the managed version of the entity. So you want to use the return-value, not the argument you passed ;)

--
Jasper N. Brouwer


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nick Walke  
View profile  
 More options Nov 15 2012, 9:18 am
From: Nick Walke <tubaguy50...@gmail.com>
Date: Thu, 15 Nov 2012 06:18:00 -0800 (PST)
Subject: Re: [doctrine-user] Broken entities using detach, Doctrine APC cache driver, and merge

That makes sense.  Thank you!  They're both returning true now.

On Thursday, November 15, 2012 2:48:06 AM UTC-6, Jąπ (Jasper N. Brouwer)
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »