Hello

I'm stuck at exactly the same problem. Is there any solution?

Thank you for your help!

Sebastian

Am Sonntag, 30. März 2014 17:34:18 UTC+2 schrieb Benjamin Morel:
>
> Hi all, I have the following entity:
>
> class Restaurant{
>     /**
>      * @OneToMany(targetEntity="CollectionTime", mappedBy="restaurant")
>      */
>     protected $collectionTimes;
>
>     /**
>      * @OneToMany(targetEntity="DeliveryTime", mappedBy="restaurant")
>      */
>     protected $deliveryTimes;}
>
> Mapping to two subclasses of the same entity:
>
> /**
>  * @Entity
>  * @InheritanceType("SINGLE_TABLE")
>  * @ORM\DiscriminatorMap({
>  *   "CollectionTime" = "CollectionTime",
>  *   "DeliveryTime"   = "DeliveryTime"
>  * })
>  */abstract class OrderTime{
>     /**
>      * @ManyToOne(targetEntity="Restaurant")
>      */
>     protected $restaurant;}
> /**
>  * @Entity
>  */class CollectionTime extends OrderTime{}
> /**
>  * @Entity
>  */class DeliveryTime extends OrderTime{}
>
> Now the problem is, doctrine orm:validate-schema reports the following 
> errors:
>
>
>    - 
>    
>    The field Restaurant#collectionTimes is on the inverse side of a 
>    bi-directional relationship, but the specified mappedBy association on the 
>    target-entity CollectionTime#restaurant does not contain the required 
>    'inversedBy=collectionTimes' attribute.
>    - 
>    
>    The field Restaurant#deliveryTimes is on the inverse side of a 
>    bi-directional relationship, but the specified mappedBy association on the 
>    target-entity DeliveryTime#restaurant does not contain the required 
>    'inversedBy=deliveryTimes' attribute.
>    
> In short, Doctrine expects every mappedBy to have an inversedBy on the 
> other side.
>
> The only solution I can see so far is to move the OrderTime::$restaurant 
> property 
> and mapping to CollectionTime and DeliveryTime, just to be able to add 
> the proper inversedBy mapping:
>
> abstract class OrderTime{}
> /**
>  * @Entity
>  */class CollectionTime extends OrderTime{
>     /**
>      * @ManyToOne(targetEntity="Restaurant", inversedBy="collectionTimes")
>      */
>     protected $restaurant;}
> /**
>  * @Entity
>  */class DeliveryTime extends OrderTime{
>     /**
>      * @ManyToOne(targetEntity="Restaurant", inversedBy="deliveryTimes")
>      */
>     protected $restaurant;}
>
> But it is cumbersome and goes against the principle of inheritance.
>
> *Is there a way to just override the inversedBy attribute in the 
> subclasses, without having to (re)declare the whole property in the 
> subclass?*
>
> I've looked into @AssociationOverrides 
> <http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html#association-override>
>  and @AttributeOverrides 
> <http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html#attribute-override>,
>  
> but they don't seem to be designed for this purpose.
>
> Thanks for any hint!
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to