Doctrine orm Doctrine2映射一个ID';不是实体,而是实体

Doctrine orm Doctrine2映射一个ID';不是实体,而是实体,doctrine-orm,Doctrine Orm,是否可以创建从一个实体a到实体B的映射,而只在实体a中存储一个数组,该数组只包含相关实体B的ID class A { /** * @var int */ protected $id; /** * @var int[] One to many relationship which only has the ID's of class B */ private $bIds; ... } class B {

是否可以创建从一个实体a到实体B的映射,而只在实体a中存储一个数组,该数组只包含相关实体B的ID

class A
{
    /**
     * @var int
     */
    protected $id;
    /**
     * @var int[]    One to many relationship which only has the ID's of class B
     */
    private $bIds;

    ...
}

class B
{
    /**
     * @var int
     */
    protected $id;
    /**
     * @var A    Many to one relationship
     */
    private $a;
}

您仍然需要加载那些相关的实体。那么,为什么不在
a
上使用一个helper方法将id作为数组返回呢?显然不是。在irc频道上聊天,似乎我可以通过定制回购/回购组合来实现。即使这样也不是一个完整的解决方案,因为实体经理不知道如何保持这种关系。显然,这只是目前理论的一个限制,你仍然需要加载那些相关的实体。那么,为什么不在
a
上使用一个helper方法将id作为数组返回呢?显然不是。在irc频道上聊天,似乎我可以通过定制回购/回购组合来实现。即使这样也不是一个完整的解决方案,因为实体经理不知道如何保持这种关系。显然,这只是目前理论的局限性