You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Using Kotlin I use BsonProperty on a field and the key name seems ignored when the entity is persisted but BsonProperty value is used when reading the document.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.864 s <<< FAILURE! - in org.acme.mongodb.panache.PersonResourceTest
[ERROR] testHelloEndpoint Time elapsed: 1.204 s <<< ERROR!
org.bson.codecs.configuration.CodecConfigurationException:
An exception occurred when decoding using the AutomaticPojoCodec.
Decoding into a 'Person' failed with the following exception:
Could not construct new instance of: Person. Missing the following properties: [first_name]
A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.
at org.acme.mongodb.panache.PersonResourceTest.testHelloEndpoint(PersonResourceTest.kt:31)
Caused by: org.bson.codecs.configuration.CodecConfigurationException: Could not construct new instance of: Person. Missing the following properties: [first_name]
at org.acme.mongodb.panache.PersonResourceTest.testHelloEndpoint(PersonResourceTest.kt:31)
Caused by: org.bson.codecs.configuration.CodecConfigurationException
at org.acme.mongodb.panache.PersonResourceTest.testHelloEndpoint(PersonResourceTest.kt:31)
Caused by: org.bson.codecs.configuration.CodecConfigurationException
at org.acme.mongodb.panache.PersonResourceTest.testHelloEndpoint(PersonResourceTest.kt:31)
Caused by: java.lang.reflect.InvocationTargetException
at org.acme.mongodb.panache.PersonResourceTest.testHelloEndpoint(PersonResourceTest.kt:31)
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method org.acme.mongodb.panache.Person.<init>, parameter name
at org.acme.mongodb.panache.PersonResourceTest.testHelloEndpoint(PersonResourceTest.kt:31)
This is not a Quarkus issue, but an issue with the application itself.
The proper way to use the data class of the reproducer:
@MongoEntity(collection = "person")
data class Person @BsonCreator constructor(
@get:BsonProperty("first_name") @param:BsonProperty("first_name") var name: String
) : PanacheMongoEntityBase()
Describe the bug
Using Kotlin I use
BsonProperty
on a field and the key name seems ignored when the entity is persisted butBsonProperty
value is used when reading the document.The initial discussion on Zulip
Expected behavior
The
BsonProperty
value is used when the document is persisted.Actual behavior
The
BsonProperty
value is not ignored.To Reproduce
Here is a reproducer
The relevant part:
Configuration
The text was updated successfully, but these errors were encountered: