From e01510953eaa771391ad26effb3f5606fe15ad04 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Fri, 30 Apr 2010 16:11:35 -0400 Subject: [PATCH] [DDC-443] Adding many-to-one unidirectional example --- manual/en/association-mapping.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/manual/en/association-mapping.txt b/manual/en/association-mapping.txt index 02c59675d..d89756220 100644 --- a/manual/en/association-mapping.txt +++ b/manual/en/association-mapping.txt @@ -224,6 +224,33 @@ The following example sets up such a unidirectional one-to-many association: > **NOTE** > One-To-Many uni-directional relations with join-table only work using the @ManyToMany annotation and a unique-constraint. +++ Many-To-One, Unidirectional + +You can easily implement a many-to-one unidirectional association with the following: + + [php] + /** @Entity */ + class User + { + // ... + + /** + * @ManyToOne(targetEntity="Address") + * @JoinColumn(name="address_id", referencedColumnName="id") + */ + private $address + } + + /** @Entity */ + class Address + { + // ... + } + +> **TIP** +> The above `@JoinColumn` is optional as it would default to `address_id` and `id` +> anyways. You can omit it and let it use the defaults. + ++ One-To-Many, Bidirectional Bidirectional one-to-many associations are very common. The following code shows an example with a Product and a Feature class: