我遇到映射不一致的問題。我在應用程序中有兩個實體 - 聯繫人(包含聯繫人的實體...)和信息,包含此聯繫人信息的實體(電話,電子郵件,傳真,網站等)。映射彼此不一致
,在我跟實體我做變量爲每種類型的,我需要在我的應用程序,因爲這樣更容易:
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactInformations;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactPhone;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactFax;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactWebsite;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactEmail;
/**
* @ORM\OneToMany(targetEntity = "RelationInformations" , mappedBy = "objectID", cascade={"persist"})
*/
protected $contactCommunicator;
而且例如吸氣的手機看起來像:
/**
* Get contactPhone
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getContactPhone()
{
if ($this->contactPhone !== null) {
foreach ($this->contactPhone->toArray() as &$info) {
if ($info->getType() !== RelationInformations::TYPE_TELEPHONE) {
$this->contactPhone->removeElement($info);
}
}
}
return $this->contactPhone;
}
這樣我只通過使用這個函數從我的信息中獲得手機,所以在應用程序的其他地方更容易得到我想要的。
RelationInformation實體:
/**
* @var integer
* @ORM\Column(name = "rnis_id" , type = "integer" , nullable = false);
* @ORM\Id
* @ORM\GeneratedValue(strategy = "AUTO")
*/
private $id;
/**
* @var integer
* @ORM\ManyToOne(targetEntity = "RelationContact" , inversedBy = "contactInformations")
* @ORM\JoinColumn(name = "rnis_object_id" , referencedColumnName="rnct_id", nullable = false);
*/
private $objectID;
/**
* @var string
* @ORM\Column(name = "rnis_value" , type = "string" , nullable = false )
*/
private $value;
/**
* @var string
* @ORM\Column(name = "rnis_type" , type = "string" , nullable = false , length = 1)
*/
private $type;
/**
* @var boolean
* @ORM\Column(name = "rnis_active" , type = "boolean" , nullable = false)
*/
private $active;
/**
* @var boolean
* @ORM\Column(name = "rnis_default" , type = "boolean" , nullable = false)
*/
private $default;
/**
* @var string
* @ORM\Column(name = "rnis_txt" , type = "string" , nullable = true)
*/
private $txt;
/**
* @var integer
* @ORM\Column(name = "rnis_type_private_business" , type = "integer" , nullable = true)
*/
private $typePrivateBusiness;
的問題是,在我的探查,我可以看到類似波紋管的錯誤。應用程序正常工作,但我想解決這個問題。
The mappings RelationContact#contactPhone and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactFax and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactWebsite and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactEmail and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactCommunicator and RelationInformations#objectID are inconsistent with each other.
The mappings RelationContact#contactBrand and RelationInformations#objectID are inconsistent with each other.
請張貼實體'RelationInformations' – Matteo 2014-10-08 10:06:03
確定的代碼,我已經將其添加;) – 2014-10-08 10:09:55