I have this class structure
UserInterface
--- abstract Class User extends UserInterface
class Teacher extends User
Now i am using class Table inheritance
so in dtabase i have two tables User
and Teacher with FK to User
I am persisting abstract class like this
/**
* @ORM\Entity(repositoryClass="xxxx\UserBundle\Repository\UserRepository")
* @ORM\HasLifecycleCallbacks
* @ORM\Table(name="user")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"puser" = "User", "teacher" = "Teacher"})
*/
abstract class User implements UserInterface, GroupableInterface
{
I want to know that am i doing right???
As an Abstract class can not be initiated you can not persist it with Doctrine. You can persist classes which extends the Abstract class which in this case is Teacher.