Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedded relation object without extra query #242

Open
JuanLuisGarciaBorrego opened this issue Dec 10, 2016 · 0 comments
Open

Embedded relation object without extra query #242

JuanLuisGarciaBorrego opened this issue Dec 10, 2016 · 0 comments
Labels

Comments

@JuanLuisGarciaBorrego
Copy link

JuanLuisGarciaBorrego commented Dec 10, 2016

Hello
How can I tell Hateoas\Relation that using embedded does not create an extra query?

From my controller to retrieve the data I create a query with join, and then Hateas creates another when I use embedded

Entity:

/**
 * Local
 *
 * @ORM\Table(name="local")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\LocalRepository")
 *
 * @Serializer\ExclusionPolicy("all")
 *
 * @Hateoas\Relation(
 *     "self",
 *     href = @Hateoas\Route(
 *         "api_local_show",
 *         parameters={ "code" = "expr(object.getId())" }
 *     ),
 *     embedded="expr(object.getExtra())"
 * )
 */
class Local
{
    ....
    /**
     * @var Extra
     *
     * @ORM\OneToOne(targetEntity="Extra")
     * @ORM\JoinColumn(name="extra_id", referencedColumnName="id")
     *
     * @Serializer\Exclude()
     */
    private $extra;
}

I do not know if I explained correctly, thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants