It seemed that I closed the Relation annotation to early.
Updated entity:
<?php
namespace My\Entity;
use Doctrine\ORM\Mapping as ORM;
use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
* @ORM\Table(name="`order`")
* @ORM\HasLifecycleCallbacks
*
* @Hateoas\Relation(
* "self",
* href = "expr('/order/' ~ object.getId())",
* exclusion = @Hateoas\Exclusion(
* groups = {"production"}
* )
* )
* @Hateoas\Relation(
* "self",
* href = "expr('/production/' ~ object.getId())",
* exclusion = @Hateoas\Exclusion(
* groups = {"order"}
* )
* )
*/
class Order
{
}