Hello there,

forget about it, I found the issue.

We were using groups for the output, turns out you have to set the same
groups for the child class or there will be no output. Makes sense.



Regards,


On Sat, Feb 16, 2013 at 9:12 PM, Jordi Molina <[email protected]> wrote:

> Hello there,
>
> I'm using JMSSerializer to encode a entity that has a relationship with
> another one into json, what I'm trying to do is to fetch the parent one,
> and get the related one as a set of fields in the json, but what happens is
> that I get is 2 empty fields.
>
> I've defined the entities like that:
>
> *Main entity*
>
>> class ftrInvoice {
>>     /**
>>      * @ORM\Id
>>      * @ORM\Column(type="integer")
>>      * @ORM\GeneratedValue(strategy="AUTO")
>>      * @Groups({"summary","full"})
>>      * @Type("integer")
>>      */
>>     protected $invoiceId;
>>     /**
>>      * @ORM\Column(type="string", length=100)
>>      * @Groups({"summary","full"})
>>      * @Type("string")
>>      */
>>      protected $invoiceNumber;
>>     /**
>>     * @ORM\OneToMany(targetEntity="ftrLineTerm",
>> mappedBy="invoiceId",cascade={"persist"})
>>     * @Groups({"full"})
>>     */
>>     protected $lineTerms;
>> }
>
>
>
> *Related entity*
>
>> /**
>>  * @ORM\Entity
>>  * @ORM\Table(name="ftrLineTerm")
>>  *
>> @ORM\Entity(repositoryClass="Afinic\FacturatorBundle\Repository\ftrLineTermRepository")
>>  * @ExclusionPolicy("None")
>>  */
>> class ftrLineTerm {
>>     /**
>>      * @ORM\Id
>>      * @ORM\Column(type="integer")
>>      * @ORM\GeneratedValue(strategy="AUTO")
>>      * @Type("integer")
>>      */
>>     protected $lineTermId;
>>     /**
>>      * @ORM\ManyToOne(targetEntity="ftrInvoice", inversedBy="lineTerms")
>>      * @ORM\JoinColumn(name="invoiceId", referencedColumnName="invoiceId")
>>      */
>>     protected $invoiceId;
>>      /**
>>      * @ORM\Column(type="integer")
>>      * @Type("integer")
>>      */
>>     protected $productId;
>> }
>
>
> When I, from a controller, get a specific invoice and serialize it to JSON
> with the following code:
>
>>         $invoice =
>> $em->getRepository('AfinicFacturatorBundle:ftrInvoice')->findOneByInvoiceId($id);
>>         $serializer = $this->container->get('serializer');
>>         $serializer->setGroups(array('full'));
>>         $result = $serializer->serialize($invoice, 'json');
>
>
> and return it as a response, what I get is:
>
> {"invoice_id":1,"invoice_number":"WARP-0000001","line_terms":[[],[]]}
>
>
>
> There are actually 2 registers in the entity ftrLineTerm for the
> invoice_id 1, but as you can see, I don't get any of the properties of
> line_terms serialized :(
>
>
> does anybody know what may be happening?
>
>
> many thanks and sorry for my english!
>
>  --
> --
> If you want to report a vulnerability issue on Symfony, please read the
> procedure on http://symfony.com/security
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Symfony developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Jordi Molina Casas (warp3r)
mail: [email protected] 4BC8 8150 7B1A FC24 FBAD  7B07 FE90 F300 4F36 3BF7
mail: [email protected] 2F91 EF95 229E FC31 18C0  05C3 B320 22DA 8C03 F33E
www: www.warp3r.com (personal blog) sysadmin.warp3r.com (sysadmin related
site)
openid: https://openid.warp3r.com/?user=warp3r

-- 
-- 
If you want to report a vulnerability issue on Symfony, please read the 
procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Symfony developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to