我在尝试更新对象时偶然发现了这个错误,但无法找到任何解释。这是我的代码:
实体
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');
}
我对其他实体做了同样的事情并没有问题,我不知道这个有什么问题。我验证了学说模式,没有错。
答案 0 :(得分:7)
我想我太累了,不会注意到这个惊人的$ em-flush拼写错误:))) 好家伙!这是一个奇怪的,我花了30分钟试图找出这个错误,从来没有怀疑错字。希望它能在某一天挽救某人的生命:))