Symfony 注意:类条令\ORM\EntityManager的对象无法转换为int

Symfony 注意:类条令\ORM\EntityManager的对象无法转换为int,symfony,doctrine,entitymanager,Symfony,Doctrine,Entitymanager,我在试图更新对象时偶然发现了这个错误,但找不到任何解释。这是我的密码: 实体 namespace Mnv\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Class UtilitatiVariabile * @package Mnv\CoreBundle\Entity * * @ORM\Table(name="utilitati_variabile") * @ORM\Entity(repositoryCla

我在试图更新对象时偶然发现了这个错误,但找不到任何解释。这是我的密码:

实体

    namespace Mnv\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Class UtilitatiVariabile
 * @package Mnv\CoreBundle\Entity
 *
 * @ORM\Table(name="utilitati_variabile")
 * @ORM\Entity(repositoryClass="Mnv\CoreBundle\Entity\Repository\UtilitatiVariabileRepository")
 */
class UtilitatiVariabile {

    /**
     * @var integer
     *
     * @ORM\Id()
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer")
     */
    protected $id;

    /**
     * @var float
     *
     * @ORM\Column(type="decimal", precision=10, scale=6, nullable=true)
     */
    protected $coeficient;

    /**
     * @var float
     *
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $kwh;

    /**
     * @var float
     *
     * @ORM\Column(name="original_kwh", type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $originalKwh;

    /**
     * @var float
     *
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $mc;

    /**
     * @var float
     *
     * @ORM\Column(name="original_mc", type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $originalMc;

    /**
     * @var float
     *
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $lei;

    /**
     * @var float
     *
     * @ORM\Column(name="original_lei", type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $originalLei;

    /**
     * @var float
     *
     * @ORM\Column(type="decimal", precision=10, scale=6, nullable=true)
     */
    protected $leikw;

    /**
     * @var float
     *
     * @ORM\Column(type="decimal", precision=10, scale=6, nullable=true)
     */
    protected $leimc;

    /**
     * @var float
     *
     * @ORM\Column(name="suprafata_totala", type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $suprafataTotala;

    /**
     * @var float
     *
     * @ORM\Column(name="total_col_mc", type="decimal", precision=20, scale=2, nullable=true)
     */
    protected $totalColMc;

    /**
     * @var float
     *
     * @ORM\Column(name="total_col_kwh", type="decimal", precision=20, scale=2, nullable=true)
     */
    protected $totalColKwh;

    /**
     * @var float
     *
     * @ORM\Column(name="total_col_lei", type="decimal", precision=20, scale=2, nullable=true)
     */
    protected $totalColLei;

    /**
     * @var float
     *
     * @ORM\Column(name="total_col_total", type="decimal", precision=20, scale=2, nullable=true)
     */
    protected $totalColTotal;

    /**
     * @var Utilitati
     *
     * @ORM\ManyToOne(targetEntity="Utilitati")
     * @ORM\JoinColumn(name="id_utilitate", referencedColumnName="id", onDelete="SET NULL")
     */
    protected $utilitate;

    /**
     * @var SesiuneUtilitati
     *
     * @ORM\ManyToOne(targetEntity="SesiuneUtilitati")
     * @ORM\JoinColumn(name="id_sesiune", referencedColumnName="id", onDelete="CASCADE")
     */
    protected $sesiuneUtilitati;
我尝试在控制器中进行如下更新:

$variables = $this->getVariabileRepository()->find(1);
$variables->setKwh($kwh);
        .
        .
        .
        $em = $this->getEntityManager();
        $em->persist($variables);
        $em-flush();




   protected function getEntityManager()
        {
            return $this->getDoctrine()->getManager();
        }

    protected function getVariabileRepository()
    {
        return $this->getEntityManager()->getRepository('MnvCoreBundle:UtilitatiVariabile');
    }

我对其他实体也做了同样的处理,没有问题,我不知道这一个有什么问题。我验证了条令模式,没有任何错误。

我想我太累了,以至于没有注意到奇怪的$em flush打字错误:))
哦,孩子!这是一个奇怪的错误,我花了30分钟试图找出这个错误,从未怀疑有打字错误。希望有一天它能救一个人的命:)

哦,老兄,我也是这样。我的IDE甚至突出显示了它。睡眠不仅是一种乐趣,而且显然是必要的。