official documentation似乎沒有提到對此的限制。
但是,只要你想在列的關係,鑑別地圖會再靠DB-發出的ID,這是不是在我看來不錯...
但你仍然可以讓學說處理鑑別爲你:只聲明你永遠不會直接使用的鑑別器列,聲明其地圖,然後依靠實體邏輯來保持類別和文檔類型之間的一致性:
/**
* @ORM\Entity(repositoryClass="...
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({
* "youtube"="Youtube",
* "dailymotion"="Dailymotion",
* ...
* })
*/
abstract class Document {
/**
* @ORM\ManyToOne(targetEntity="Category", inversedBy="documents")
*/
protected $category;
...
//this is to be called by children that all share a category field
public function setCategory(Category $c) {
$class = get_class($this);
if (strtolower($c->getName()) !== strtolower(substr($class, strrpos($class, '\\') + 1))) {
throw new \LogicException("Cannot bind " . $class . " to category " . $c->getName());
}
$this->category = $c;
return $this;
}