[FLOW3-general] collection and mapping problem

"Christian Müller (Kitsunet)" christian.mueller at typo3.org
Mon Aug 29 08:03:39 CEST 2011


Try with:


@var 
\Doctrine\Common\Collections\ArrayCollection<\MyPackage\Model\Domain\Address>

and yes you should define the type of association too. Probably @OneToMany

and you should define them to be opposite sites of the same relation 
with mappedBy and inversedBy, check eg. FLOW3 and Party Package Models 
and the doctrine docs:
http://www.doctrine-project.org/docs/orm/2.1/en/reference/association-mapping.html

cheers,
Christian

On 28/08/11 17:44, Dawid Pacholczyk wrote:
> Hello List,
> I have problem with mapping a field.
>
> I`m creating something like this.
>
> I have User na Address
>
> User can have manny addresses but 1 address can be attached to 1 user
>
> So I`ve Address which has
>
> /**
> * @var \MyPackage\Model\Domain\User
> * @ManyToOne(targetEntity="MyPackage\Domain\Model\User")
> */
> protected $user;
>
> It works like I want to
>
> In User model I`ve created this:
>
> /**
> * @var SplObjectStorage<\MyPackage\Model\Domain\Address>
> */
> protected $addresses;
>
> I didn`t have problem in the first version of alpha 15. I could validate
> it and make an update. yesterday I`ve pulled latest source and doctrine
> told me that this field has no type.
>
> "The attribute 'type' is required for the column description of property
> MyPackage\Domain\Model\User::$addresses."
>
> I want to have a collections of addresses in my user table.
>
> Tbh when I`m writing this I`ve started to think about association.
> Shouldn`t it be some kind of association to addresses ? Like many to
> many ? But this is second question.
>
> First is. Why can`t I create field with this kind of type ?
>
> Best regards,
> Dawid Pacholczyk



More information about the FLOW3-general mailing list