doubeiji2602 2016-02-02 09:02
浏览 33

Doctrine没有在dev env上看到映射,但它在测试环境中看到了映射

I have some weird behaviour of doctrine. I've been fighting it since yesterday and I cannot solve the problem.

I have class A that has unidirectional mapping to class B. I have created test for class A that retrives object B

public function setUp()
{
    self::bootKernel();

    $this->container = self::$kernel->getContainer();
    $this->em = $this->container->get('doctrine.orm.entity_manager');
}

public function testStreamingMatchReturnsGuthMatchTable()
{
    $a = $this->em->getRepository('AppBundle:A')->find(1);
    var_dump($a->getB()); // it returns object B
}

it is working as expected and it returns object B

However when I run the same code but in dev envirorment(from the browser) not CLI it does not return mapping

the code:

public function getAction($id) 
{
    $a = $this->get('doctrine.orm.entity_manager');
    $a = $this->em->getRepository('AppBundle:A')->find(1);
    var_dump($a->getB()); // it returns null
}

Relation is marked as:

class A
{
     /* 
      * @ORM\OneToOne(targetEntity="B")
      * @ORM\JoinColumn(name="b_id", referencedColumnName="id")
      */
      private $b;
}

It isn't original code but it illustrates the problem.

So my question is, how to make relations work in dev environment or what can cause the problem in dev env?

What I've tried already:

  • clear cache
  • disable cache
  • change mapping
  • check with DQL // same problem
  • try run it with test config on browser

Nothing worked so far and I've got out of ideas.

Edit:

I've noticed that it creates proxy class for test env but it does not create it for dev env.

Edit 2

I've tried to run it on build in Symfony2 server and it works. It does not work on Nginx(vagrant).

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答