Doctrine Second Level Association Cache misses

---------------------

User Entity:

/**
 * User
 *
 * @ORMTable()
 * @ORMEntity()
 * @ORMCache(usage="NONSTRICT_READ_WRITE")

// ....

/**
 * Cars of the user.
 *
 * @var ArrayCollection
 * @ORMCache(usage="NONSTRICT_READ_WRITE")
 * @ORMOneToMany(targetEntity="AcmeCarBundleEntityCar", mappedBy="user")
 */
protected $cars;

----------------------

Car Entity:

 * @ORMEntity()
 * @ORMTable()
 * @ORMCache(usage="NONSTRICT_READ_WRITE")

// ...

/**
 * Owner of the car
 *
 * @var UserInterface
 *
 * @ORMCache(usage="NONSTRICT_READ_WRITE")
 * @ORMManyToOne(targetEntity="AcmeUserBundleEntityUser", inversedBy="cars")
 * @ORMJoinColumn(referencedColumnName="id")
 */
protected $user;

The problem is, that acme_userbundle_entity_user__cars never hits the cache, but puts it in every time..

Second Level Cache:

acme_carbundle_entity_car           cache hits: 8 // OK

acme_userbundle_entity_user           cache hits: 6 // OK

acme_userbundle_entity_user__cars    cache misses: 1 // WHY?

acme_userbundle_entity_user__cars    cache puts: 1 // WHY?


Source: New Questions

Leave a Reply