doctrine2 - In symfony2 using jmsSerializerBundle to serialize then deserialize a subentity throws exception when parent entity is saved -



doctrine2 - In symfony2 using jmsSerializerBundle to serialize then deserialize a subentity throws exception when parent entity is saved -

my app has entity called "client" injected every request object.

to improve performance i've set custom cache, , using jmsserializer serialize , cache client objects. when request comes in, cache returns serialized client object, , jms deserializes it.

my application creates other entities, phone call them childentities, , associates them client objects via manytoone relationship on childentity.

this working fine until started loading these objects via deserializing cached data, rather using doctrine load them mysql database. doctrine throws error:

a new entity found through relationship "\acme\bundle\entity\childentity#client" not configured cascade persist operations entity: clientname. solve issue: either explicitly phone call entitymanager#persist() on unknown entity or configure cascade persist association in mapping illustration @manytoone(..,cascade={"persist"})

so, if i'm understanding error properly, seems doctrine thinks client object referenced manytoone relationship on childentity object new object (even though i'm deserializing id) needs save, won't because no cascading set up.

is strategy of deserializing objects wrong? there way deserialize them proxy objects, or other solution problem? prefer utilize custom cache doctrine cache.

figured 1 out when found right search phrase.

i using default object constructor, needed using doctrine object constructor.

to so, added services.yml:

jms_serializer.object_constructor: alias: jms_serializer.doctrine_object_constructor public: false

symfony2 doctrine2 jmsserializerbundle

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -