-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OneToOne relationship with owning side having key of inverse side broken #6124
Comments
I executed that gist (just changing the names to GH6124* to relate to this issue) and I had a different error on Basically the ORM complains that it wasn't able to call the method
|
I think that may be related then; in this circumstance the owning side |
We need to think about what should be the behaviour of the L2C query regarding this... I mean, we could easily hack something on private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue)
{
$assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']);
$assocMetadata = $assocPersister->getClassMetadata();
if (!$assocPersister instanceof Cache\Persister\Entity\CachedEntityPersister) {
return []; // returning null would invalidate the whole query cache entry
}
// ...
} But is this right? |
Maybe @guilhermeblanco can help us on this one |
Also mentioned on #5808 (but here we have more detail). |
@asgrim @Ocramius I was investigating this issue last evening and unfortunately my conclusion is that is not really worth to have a way to workaround the cache on this situation. My suggestion is to simply make the schema validator add a warning. The reason for this is the way the ORM handles one-to-one associations. What are your thoughts? |
A limitation warning referencing an issue is sufficient for me.
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
…On Wed, Feb 22, 2017 at 10:10 AM, Luís Cobucci ***@***.***> wrote:
@asgrim <https://github.com/asgrim> @Ocramius
<https://github.com/Ocramius> I was investigating this issue last evening
and unfortunately my conclusion is that is not really worth to have a way
to workaround the cache on this situation.
My suggestion is to simply make the schema validator add a warning. The
reason for this is the way the ORM handles one-to-one associations.
What are your thoughts?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6124 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakOL5R08jRUZXSQY36Lr3G2VzmOSLks5re_ubgaJpZM4KtlTJ>
.
|
@lcobucci Did you re-run the test? It seems we already check for that in https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/DefaultQueryCache.php#L249 and this shouldn't happen anymore. However, it might be worth looking into switching the association to owning side and caching the owning side (which must be cacheable, or you would have an exception). I'm long away of master (in develop there's no more |
@guilhermeblanco I did. On master the problem is not the I agree that we shouldn't allow that on
That's excellent! |
@lcobucci Makes sense now... however I don't think it's a matter of implying to have a Whenever you have a class like this: /**
* @Entity
* @Cache
*/
class User {
/**
* @Id @GeneratedValue @Column(type="integer")
*/
public $id;
/**
* @ManyToOne(targetEntity="Group")
*/
public $group;
/**
* @OneToMany(targetEntity="Phone")
* @Cache
*/
public $phones = [];
} In this scenario, it is expected to have 2 cache entries: $entries = [
'region_name:user_1_hash' => ['id'=> 1, 'group'=>['id'=>1]],
'region_name:user_1_phones_hash' => ['ownerId'=> 1, 'list' => [1, 2, 3]],
]; As you may see, we don't necessarily need to add There's also the limitation we introduced that other side must be cached (which means, both However, it's an optional action to cache the collection association (*-to-many), and implicit for *-to-one (owning side) associations. Things get tricky when you have bi-directionals. I think it's worth discussing on this thread and properly implement. I don't think we should add a warning anywhere tbh. |
@guilhermeblanco it's not about So my suggestion to only force the |
@Ocramius @guilhermeblanco I was thinking about move this to |
Full ack - this can be fixed easily now that we have a stricter metadata API thanks to @guilhermeblanco's efforts. |
Is there a solutions for ppl who are waiting for this to be fixed? in the mean time of 3.0? |
@Webonaute if you didn't see one in the thread: no. |
@Webonaute did you try:
|
OneToOne met halve caching werkt ook niet helemaal goed: doctrine/orm#6124
Hey, I just hit this issue when attempting to enable L2 cache for our application. Is there truly nothing else other than making it a OneToMany relationship? It breaks some assumptions in the db which is... not preferable, obviously. I was hoping it'd be as simple as enabling cache on a couple of our entities but since the relationships are complex (about 190 entities) lack of support for this is a deal breaker, and L2 is essentially unusable. Is there a reason it was moved away from a 3.0 release milestone? I'd love to see this resolved in the near future. Perhaps for now it'd be okay to simply mention that 1:1 relationships cannot be cached and instead either load them from database on request as usual or eagerly if set? It seems to me one could simply store some metadata instead which would tell it which cache key to read or if to pull it from db instead. |
gist created by @Ocramius shows a reproducible case for this issue: https://gist.github.com/Ocramius/7adc2079884991122ca95a74d2eb4927
When hydrating an entity constructed as per the gist above using
findOneBy
, the ORM raises a notice startingNotice: Undefined index: targetToSourceKeyColumns
. I believe the issue is not reproducible when usingfind
.Unsure as to the root cause of the issue currently. Apologies for the vague description here, but @Ocramius will hopefully be able to provide more detail about this issue.
The text was updated successfully, but these errors were encountered: