Deserialize JSON with Association using JMSSerializer

236 views Asked by At

In my project, I need to update Doctrine2 entities with JMSSerializer. My JSON looks like this:

{"id":28,"prefixes":[{"id":8},{"id":11},{"id":14}]}

My entity defines prefixes as a ManyToMany association. I'm already using the Doctrine Object Constructor.

When I attempt to deserialize the JSON, JMSSerializer deserializes the prefixes as new entities, which results in this error:

A new entity was found through the relationship 'PartKeepr\\UnitBundle\\Entity\\Unit#prefixes' that was not configured to cascade persist operations for entity

Any light on what's going on?

1

There are 1 answers

0
Drachenkatze On

The question is obsolete, as the issue occured because I had two entity managers in place: One legacy and one from doctrine.