-
Notifications
You must be signed in to change notification settings - Fork 455
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
StackOverflow while trying to lookup entities having reference to no-longer-existing entity #2382
Comments
@h-arlt if you could take a look at the updated test, i think this will get you what you need. I had to update the test because some assumptions didn't apply but this push should fix the problem for you. If you'd like to run it locally, you can test against 2.3.5-SNAPSHOT which should be online shortly in the central snapshots repo. |
Updated test looks fine to me and works like a charm with latest 2.3.x 🎉 PS: To satisfy my tester paranoia, I'd change line 53 to root = datastore.find(RootEntity.class).filter(eq("ignoreMissing", p)).first();
assertNotNull(root); |
done. :) though it should be |
2.3.5 is now live |
Just out of curiosity, why won't the query find a matching document? Is there any existence check on the referenced document involved? I'd rather expect a simple equality check on property |
It wouldn't find it because the query is asking, "can you find me this A that references this B?" and the answer is no because that B doesn't exist any more. |
Exactly. That's what I'd expect when the reference wouldn't be marked with Don't want to bother you; I'm just trying to understand the implications and limitations when working with Morphia references. |
|
In my example above, What about My use case is as follows: I use a reference to model a weak relation between two types of entities. This reference is marked as lazy, ignoreMissing and idOnly. At some point in time, some of the referenced documents vanish from DB (e.g. deleted in course of user interaction with the the app). Now, in order to find all documents that have a dangling reference, I need to query for the reference's field having an ID of one of the deleted documents. |
I see. With the way references are currently done internally, that will be tricky with a query. (I'm reworking how references are handled in 3.0 to clean (hopefully) all of that up.) Probably the most semantically reading way to do what you need here is with a |
Roger that. As long as there is a way I'm happy ;) Thanks for clarification and the efforts you put in this project! Appreciate it 👍 |
Describe the bug
Attempts to query for entities using an equality filter on a field annotated with
@Reference(lazy=true, idOnly=true)
causes StackOverflow errors in case the referenced entity has gone.To Reproduce
Steps to reproduce the behavior:
r
- annotated as described above.r
into a local variable (should be a proxy instance).r
and value of variable from step 3.Expected behavior
Query succeeds w/o any issues.
** Please complete the following information: **
Additional context
The text was updated successfully, but these errors were encountered: