【问题标题】:neo4j ogm returns not all relationshipsneo4j ogm 并非返回所有关系
【发布时间】:2016-05-28 02:50:48
【问题描述】:

这是我的 omg 课程:

/**
 * @OGM\Node(label="Personne")
 */
class Personne
{
    /**
     * @OGM\GraphId()
     */
    protected $id;

    /**
     * @OGM\Property(type="string")
     */
    protected $nom;

    /**
     * @OGM\Relationship(targetEntity="Personne", type="SUIT", direction="OUTGOING")
     */
    protected $amis;

我使用这个代码:

$marc = $this->em->getRepository(Personne::class)->findOneBy('nom', 'marc');

print_r($marc->getAmis());

但它只返回 1 个关系,而不是全部,有什么问题?

【问题讨论】:

    标签: php neo4j graphaware neo4j-php-ogm


    【解决方案1】:

    它只返回一个相关的“Personne”,因为您没有将 amis 属性定义为映射中的集合:

    @OGM\Relationship注解中添加collection=true

    注意:在 PHP 7.1 中,类型化的属性可以进入,OGM 的未来版本可能会利用它(这意味着这个版本将仅限于 7.1+)

    其实我认为如果发现不止一个关系,OGM应该抛出异常。

    【讨论】:

      猜你喜欢
      • 2016-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-20
      相关资源
      最近更新 更多