question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ManyToMany self referencing and exceeded number of join relations exception

See original GitHub issue

Hi,

First of all, big thanks for api-platform it’s amazing.

I have the Campaign resource:

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * A campaign.
 *
 * @ORM\Entity()
 */
class Campaign
{
    /**
     * @Groups({"campaign_list", "campaign_get"})
     *
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @Groups({"campaign_list", "campaign_get"})
     *
     * @ORM\Column
     */
    private $name;

    /**
     * @Groups({"campaign_get"})
     *
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Campaign")
     */
    private $excluded;
}

When I try to GET /campaigns I get this exception:

The total number of joined relations has exceeded the specified maximum. Raise the limit if necessary.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
soyukacommented, Nov 28, 2016

Indeed, you have a recursive relation here, where campaign is referencing itself. You may want to disable eager loading here by using @ApiResource(attributes={"force_eager"=false}).

0reactions
cvecommented, Feb 3, 2017

@clementtalleu I didn’t have to change enythink, becasue @Simperfit pull request resolves my issue, which version of api platform do you have?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Doctrine2 ManyToMany Self referencing - Stack Overflow
I got problems with persisting many to many self referencing relations. I receive error: The class 'Doctrine\ORM\Persisters\ManyToManyPersister' was not ...
Read more >
Create a many-to-many relationship
Many-to-Many table names cannot exceed 30 characters. Reference default many-to-many relationships. Some many-to-many relationships are ...
Read more >
Web service error codes (Microsoft Dataverse) - Power Apps
Message: Relationship for polymorphic lookup cannot be self referential. The entity '{0}' cannot be the referencing and referenced entity.
Read more >
SQLObject 3.10.0 documentation
SQLObject has joins, one-to-many, and many-to-many, something which many ORMs do not have. The join system is also intended to be extensible.
Read more >
Solving 5 Mysterious Spark Errors | by yhoztak - Medium
Exception in thread "main" org.apache.spark.sql. ... Also if you don't have null, your many to many join is creating too many rows. Make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found