-
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
Misleading error message when trying to lookup discriminator of entity not mapped yet #2637
Comments
Do you want this release or not? 😄 I have a feeling I know the problem. I'll try to get that cleaned up tonight. |
I just ran your test case on |
What's the full error message you get with that? |
That's quite odd. Just checked with latest revision on 2.4.x branch and test fails with error:
|
OK. I think I've found the difference. I'd put it off in its own package which isolated it from mapping. This test introduces a duplicate mapping and that's failing but the message is poorly formed. I'll clean that up. |
Not sure if I got you right. What exactly do you mean by "duplicate mapping"? Use-case is as follows: Image you have some data stored in DB yet and your application starts up without explicitly mapping the entity types that were used to save the data in first place. If you try to load the data from DB, the discriminator lookup will fill its cache before the entity model is known to the mapper. When the mapper then tries build the model, it fails with the error message mentioned before. |
Yeah, i'm digging in now and it's weirder than I thought. There are technically two |
IMO the issue is the discriminator lookup, or more specifically, its cache that is filled in two ways: when adding an entity model and when doing a lookup for a given discriminator String value. In case the latter happens before the model is added (in EntityDecoder#decodeProperties), the error comes up. |
I found that place you mentioned about adding the lookup early. I think that went in to support mapping external types, maybe? That class is old old so some of that is lost to history. At any rate, it's all cleaned up. |
jreleaser was being fussy but 2.4.7 is up on central. |
Fix works like a charm 👍 |
Describe the bug
Attempts to load an entity from datastore that has at least one property/field of unmapped entity type fails with an error saying
After doing some debugging I noticed that the entity in question is not mapped at all but the mapper's discriminator class cache contains an entry for the entity's type which in turn triggers the error stated above.
I'm wondering whether the check in
DiscriminatorLookup#addModel
is usefull as long as there are multiple ways to fill the cache.Mapping the entity type in question explicitly before fetching the entity from DB "fixes" the issue.
To Reproduce
Run the test case below.
Expected behavior
Test either passes without any error or meaningful error message about unmapped entity type.
Please complete the following information:
Additional context
Sample test case to reproduce the issue.
The text was updated successfully, but these errors were encountered: