0

I have a problem with deserialized Doctrine entities. Serialized objects don't have all fields of the entity and when I update them so that fields are set to null. I think the same issue is here but there is no solution related to using of JMSSerializer + Doctirne.

Regards

Community
  • 1
  • 1
mrMantir
  • 2,285
  • 1
  • 17
  • 20

1 Answers1

0

Did you add to your annotations the @Expose? Sth like that

use JMS\SerializerBundle\Annotation\Expose;
use JMS\SerializerBundle\Annotation\Accessor;
use JMS\SerializerBundle\Annotation\ExclusionPolicy;
use JMS\SerializerBundle\Annotation\Type;

class MyEntity {
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     * @Expose
     * @Type("integer")
     */
    private $id;
}
Max Małecki
  • 1,700
  • 2
  • 13
  • 18
  • 1
    Hi Max. Sure - i have in my entity `@ExclusionPolicy('all')` and i set with `@Expose` what should be serialized. Problem is when i deserialize entity i have some null fields which on flush will be nulled in db. For example User entity - it would be stupid if i send salt or password in json/xml but if someone try to edit user through rest that fields will be set to null. – mrMantir Oct 02 '12 at 08:50
  • Have you found solution of this problem? – Dmytro Krasun Feb 03 '13 at 10:02