Closed mfalcier closed 3 years ago
For the ValidationException
, I suspect that @Embedded
may be required on Foo
.
However this is not a solution for the same ValidationException
problem I'm having, since I cannot use @Embedded
for embedded classes where I have to have an @Id
field (as they are also used as separate entities)...
I've tried everything @DefiantCatgirl , without success :( That is going to fix the validation, but it always result into an empty query result.
@Embedded
is definitely required. fwiw, you don't need to configure any codecs specifically like you're doing. Morphia will take care of that for you. I'll look in to the query bits today.
Running your reproducer, if I put @Embedded
on Foo
neither test fails and works as expected.
@evanchooly does It return a result? Because when I've tried It before, but the query didn't worked. I'll try it later and let you know my results. Thanks.
Yes. The query returns returns 1 item as expected.
Ok I've tried to put the @Embedded
annotation on Foo
and it worken on the first test. On the second it's not working, but I guess it's because I'm changin things on the codecs.
I've tried the annotation before, but probably only after cheating out with the codecs: since that annotation wasn't required in the past, I haven't thought it would solve the first CodecConfigurationException
.
Thanks @evanchooly for your fast reply, and I guess the issue is solved.
Use the Datastore from the test base. It's properly configured already.. but it worked with both for me.
Describe the bug I've created an entity
Employee
, and aFoo
class. The entity Employee contains an attribute with a list of Foos,Foo
is not a document.When I try to save it, I'm encountering an
org.bson.codecs.configuration.CodecConfigurationException
for the Foo class saying: "Can't find a codec for class com.foo.Foo.".I kinda avoided this issue connecting to mongo this way:
After this, I'm getting another error, since I want to query my document this way:
The error is a
dev.morphia.query.ValidationException
saying: "Could not resolve path 'foos.test' against 'com.foo.Employee'.".From here, I got stucked 2 days, and I couldn't find a workaround on it. As suggested here, I opened an issue.
To Reproduce See the attached reproducer. reproducer.zip
Expected behavior Not getting a CodecConfigurationException, since I was doing this on previous version of Morphia (1.3.2). Not getting a ValidationException, since I was doing this on previous version of Morphia (1.3.2) and on daily basis on MongoDB Compass.