I have created a base class for several entities that share the same properties, and I thought that it was a good use case for a @MappedSuperclass
:
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\MappedSuperclass
*/
abstract class Invoiceable
{
/**
* @ORM\ManyToOne(targetEntity="Invoice")
* @ORM\JoinColumn(name="invoiceId", referencedColumnName="id")
*
* @var Invoice|null
*/
protected $invoice = null;
/**
* @ORM\ManyToOne(targetEntity="CreditNote")
* @ORM\JoinColumn(name="creditNoteId", referencedColumnName="id")
*
* @var CreditNote|null
*/
protected $creditNote = null;
}
However, I was surprised that when removing the @MappedSuperclass
annotation, it still works as expected.
What is the purpose of @MappedSuperclass
superclass then, if it works without?