How do you get the associated object id without loading the associated object?

Consider an object with manyToOne one-way association:

    type: entity
    table: x
            type: integer
            generator: { strategy: AUTO }

            type: string

            targetEntity: EntityY


Any EntityY property will be loaded lazily through the proxy class; however, the EntityY will (should) be available before the proxy is loaded. What is the best way to get this ID without running the EntityY proxy loader?

Edit: I'm using Symfony2 (2.0.11) so Doctrine dependency is limited to v2.1


source to share

1 answer

Short answer: Moving to doctrine 2.2. EntityY-> getId () will no longer trigger class loading.

I've seen code for a long time that showed how to get to the UnitOfWork object and pull it out. I can not find. You can try to find the Doctrine2 users mailing list. But given that 2.2 fixes this issue, I'll just live with the download until I can upgrade.



All Articles