Unidirectional OneToMany in Doctrine 2
- by darja
I have two Doctrine entities looking like that:
/**
* @Entity
* @Table(name = "Locales")
*/
class Locale
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="IDENTITY")
*/
private $id;
/** @Column(length=2, name="Name", type="string") */
private $code;
}
/**
* @Entity
* @Table(name = "localized")
*/
class LocalizedStrings
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="IDENTITY")
*/
private $id;
/** @Column(name="Locale", type="integer") */
private $locale;
/** @Column(name="SomeText", type="string", length=300) */
private $someText;
}
I'd like to create reference between these entities. LocalizedStrings needs reference to Locale but Locale doesn't need reference to LocalizedStrings. How to write such mapping via Doctrine 2?