Doctrine 2 can't use nullable=false in manyToOne relation?

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!


Only

@ORM\JoinColumn(nullable=false)

is required