Hi Ibasaw,

If I understand correctly you want entity A to have a collection of collections 
of entity B.
I'm not sure what your use-case is, why you need something like this, but you 
can solve it by introducing another entity:

    SomeEntity <- OneToMany -> TemperatureCollection <- ManyToMany -> 
Temperature

If implemented as fully bidirectional it looks like this:

    class SomeEntity
    {
        /**
         * @ORM\OneToMany(targetEntity="TemperatureCollection", 
mappedBy="someEntity")
         */
        protected $temperatureCollections;
    }

    class TemperatureCollection
    {
        /**
         * @ORM\ManyToOne(targetEntity="SomeEntity", 
inversedBy="temperatureCollections")
         * @ORM\JoinColumn(name="some_entity_id", referencedColumnName="id")
         */
        protected $someEntity;

        /**
         * @ORM\ManyToMany(targetEntity="Temperature", 
inversedBy="temperatureCollections")
         * @ORM\JoinTable(name="temperature_collections_temperatures",
         *     joinColumns={@ORM\JoinColumn(name="temperature_id", 
referencedColumnName="id")},
         *     
inverseJoinColumns={@ORM\JoinColumn(name="temperature_collection_id", 
referencedColumnName="id")}
         * )
         */
        protected $temperatures;
    }

    class Temperature
    {
        /**
         * @ORM\ManyToMany(targetEntity="TemperatureCollection", 
mappedBy="temperatures")
         */
        private $temperatureCollections;
    }

And if you need to share those TemperatureCollections between SomeEntities, you 
could use a ManyToMany association (but this will make your object-graph quiet 
complex):

    SomeEntity <- ManyToMany -> TemperatureCollection <- ManyToMany -> 
Temperature

-- 
Jasper N. Brouwer
(@jaspernbrouwer)


On 23 Jan 2014, at 11:18, ibasaw <[email protected]> wrote:

> hi,
> 
> Don't know how to do this ?
> 
>     /**
>      * @ORM\ManyToMany(targetEntity="Temperatures", cascade={"persist", 
> "merge"}, mappedBy="temperatures")
>      */
>     protected $temperatures;
> 
>     /**
>      * @ORM\ManyToMany(targetEntity="Temperatures", cascade={"persist", 
> "merge"}, mappedBy="temperatures")
>      */
>     protected $temperatures2;
> 
>     /**
>      * @ORM\ManyToMany(targetEntity="Temperatures", cascade={"persist", 
> "merge"}, mappedBy="temperatures")
>      */
>     protected $temperatures3;
> 
> 
> thanks for your help

-- 
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/groups/opt_out.

Reply via email to