How do you get an associated entity's id without loading the associated entity?

前端 未结 1 840
北海茫月
北海茫月 2021-01-14 10:59

Consider an entity with a (unidirectional) manyToOne association:

EntityX:
    type: entity
    table: x
    id:
        id:
            type: integer
               


        
相关标签:
1条回答
  • 2021-01-14 11:29

    Short answer: Upgrade to Doctrine 2.2. EntityY->getId() will no longer trigger loading of the class.

    I did see some code a long time ago which showed how to reach into the UnitOfWork object and pull this out. Can't find it. Might try searching the Doctrine2 user mailing list. But given that 2.2 fixes this problem, I would just live with the loading until I could upgrade.

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