> --
> 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 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 doctri...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> doctrine-use...@googlegroups.com <javascript:>. >> 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
>> --
>> ______________________________**__
>> Isaac Henrique Barbosa Nunes
>> Analista e Desenvolvedor de Sistema
>> --
> 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/-/dZxcaxVTFZ4J.
> 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
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 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.
On Wed, Nov 14, 2012 at 4:11 AM, Nick Walke <tubaguy50...@gmail.com> wrote:
> That won't introduce a second copy of the company entity in the database?
> On Tuesday, November 13, 2012 9:11:14 PM UTC-6, Isaac_musashi wrote:
>>> --
>>> 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<https://groups.google.com/d/msg/doctrine-user/-/bvB5L9-bpXsJ>
>>> .
>>> To post to this group, send email to doctri...@googlegroups.com**.
>>> To unsubscribe from this group, send email to doctrine-use...@**
>>> googlegroups.com.
> 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.
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:
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.
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.
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 ;)
> 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.
> 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 ;)