Doctrine2 ArrayCollection

前端 未结 2 1077
星月不相逢
星月不相逢 2021-01-21 13:27

Ok, I have a User entity as follows



        
相关标签:
2条回答
  • 2021-01-21 13:56

    This is not yet possible in a "domain driven" way, ie. just using objects. You should execute a query to check for the existance:

    SELECT count(u.id) FROM User u WHERE ?1 IN u.urls AND u.id = ?2

    With Doctrine 2.1 this will be possible using a combination of two new features:

    1. Extra Lazy Collections
    2. @IndexBy for collections, so you would define @OneToMany(targetEntity="Url", indexBy="location")
    3. ExtraLazy Collection Support for index by using ->contains().

    Points 1 and 2 are already implemented in Doctrine 2 master, but 3 is still missing.

    0 讨论(0)
  • 2021-01-21 13:58

    You should try using the exists method on the collection and manually compare values.

    0 讨论(0)
提交回复
热议问题