Skip to content

Instantly share code, notes, and snippets.

@craue
Created November 2, 2011 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craue/1334971 to your computer and use it in GitHub Desktop.
Save craue/1334971 to your computer and use it in GitHub Desktop.
OneToOne relationship showing an issue with empty `$timespans` if no invoices exist for the timespans, concerning https://github.com/doctrine/doctrine2/pull/180
class Company {
/**
* @var Timespan[]
* @ORM\OneToMany(targetEntity="Timespan", mappedBy="company", cascade={"persist", "remove"})
*/
protected $timespans;
}
class Timespan {
/**
* @var Company
* @ORM\ManyToOne(targetEntity="Company", inversedBy="timespans")
* @ORM\JoinColumn(name="company_id", referencedColumnName="id", nullable=false)
* @Assert\NotNull
*/
protected $company;
/**
* @var Invoice
* @ORM\OneToOne(targetEntity="Invoice", mappedBy="timespan", cascade={"persist", "remove"})
*/
protected $invoice;
}
class Invoice {
/**
* @var Timespan
* @ORM\OneToOne(targetEntity="Timespan", inversedBy="invoice")
* @ORM\JoinColumn(name="timespan_id", referencedColumnName="id", nullable=false)
* @Assert\NotNull
*/
protected $timespan;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment