An User
has one Package
associated with it. Many users can refer to the same package. User
cannot exists without a Package
Only
@ORM\JoinColumn(nullable=false)
is required
Use the JoinColumn annotation on your ManyToOne relation:
/**
* @ORM\ManyToOne(targetEntity="Package", inversedBy="users")
* @ORM\JoinColumn(name="package_id", referencedColumnName="id", nullable=false)
*/
private $package;
The ManyToOne itself cannot be nullable, because it doesn't relate to a specific column. The JoinColumn on the other hand identifies the column in the database. Thus, you can use "normal" attributes like nullable or unique!