我正在 Symfony2 中创建一个项目,我正在创建实体并且我有一个 ManyToOne 关联,当我尝试从数据库中获取数据时,我收到了这个错误:
The association Ueb\Creator\Bundle\ModuleBundle\Entity\GenericBlock#fields refers to the owning side field Ueb\Creator\Bundle\ModuleBundle\Entity\GenericField#idGenericBlock which is not defined as association.
The association Ueb\Creator\Bundle\ModuleBundle\Entity\GenericBlock#fields refers to the owning side field Ueb\Creator\Bundle\ModuleBundle\Entity\GenericField#idGenericBlock which does not exist.
我有这个类的:
通用字段
/**
* GenericField
*
* @ORM\Table(name="crt_generic_field")
* @ORM\Entity(repositoryClass="Ueb\Creator\Bundle\ModuleBundle\Entity\Repository\GenericFieldRepository")
*/
class GenericField
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="id_generic_block")
* @ORM\ManyToOne(targetEntity="Ueb\Creator\Bundle\ModuleBundle\Entity\GenericBlock", inversedBy="fields")
* @ORM\JoinColumn(name="id_generic_block", referencedColumnName="id",nullable=false)
*/
private $idGenericBlock;
/**
* @var integer
*
* @ORM\Column(name="id_field_type")
* @ORM\ManyToOne(targetEntity="Ueb\Creator\Bundle\ModuleBundle\Entity\FieldTypes")
* @ORM\JoinColumn(name="id_field_type", referencedColumnName="id",nullable=false)
*/
private $idFieldType;
/**
* @var integer
*
* @ORM\Column(name="isRequired", type="integer")
*/
private $isRequired;
/**
* @var string
*
* @ORM\Column(name="field_name", type="string", length=40)
*/
private $fieldName;
/**
* @var integer
*
* @ORM\Column(name="position", type="integer")
*/
private $position;
/**
* @var string
*
* @ORM\Column(name="field_description", type="string", length=255)
*/
private $fieldDescription;
/**
* @var array
*
* @ORM\Column(name="adicional_info", type="array")
*/
private $adicionalInfo;
还有我的班级 GenericBlock
/**
* GenericBlock
*
* @ORM\Table(name="crt_generic_block")
* @ORM\Entity(repositoryClass="Ueb\Creator\Bundle\ModuleBundle\Entity\Repository\GenericBlockRepository")
*/
class GenericBlock
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="blockName", type="string", length=40)
*
*/
private $blockName;
/**
* @var string
*
* @ORM\Column(name="itemBlockName", type="string", length=40)
*/
private $itemBlockName;
/**
* @var string
*
* @ORM\Column(name="blockDescription", type="string", length=255)
*/
private $blockDescription;
/**
* @var \DateTime
*
* @ORM\Column(name="createdAt", type="date")
*/
private $createdAt;
/**
* @var integer
*
* @ORM\Column(name="createdBy")
* @ORM\ManyToOne(targetEntity="Ueb\Accounts\Bundle\UserBundle\Entity\User")
* @ORM\JoinColumn(name="createdBy", referencedColumnName="id",nullable=true)
*
*/
private $createdBy;
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="Ueb\Creator\Bundle\ModuleBundle\Entity\GenericField", mappedBy="idGenericBlock", cascade={"all"})
*/
private $fields;
我已经看到了一些具有相同错误的问题,并尝试了建议的答案,但没有一个有效,所以我不知道还能做什么,这一定是一个愚蠢的错误。