I can't get the mapping to work using native or jackson and could use some guidance.
build.gradle.kts
// plugins
kotlin("jvm") version "1.4.10"
// dependencies
implementation("org.litote.kmongo:kmongo-native:4.1.2")
db init
val client = KMongo.createClient()
codecRegistries = CodecRegistries.fromRegistries( // save uuids as UUID, instead of LUUID
CodecRegistries.fromProviders(
PojoCodecProvider
.builder()
.automatic(true)
.build()),
MongoClientSettings.getDefaultCodecRegistry()
)
mongoConnection = client.getDatabase("property").withCodecRegistry(codecRegistries())
usage
data class UserEntity @BsonCreator constructor(
@BsonId val _id: String,
@BsonProperty("name") val name: String,
@BsonProperty("email") val email: String)
database.getMongoConnection()
.getCollection<UserEntity>()
.find()
.toList()
// errors here
[qtp60559178-18] WARN org.bson.codecs.pojo - Cannot use 'UserEntity' with the PojoCodec.
java.lang.IllegalArgumentException: propertyName can not be null
Connection to db and everything else is fine.
Thanks in advance!