vertx-sql-client icon indicating copy to clipboard operation
vertx-sql-client copied to clipboard

Jackson databind support Kotlin with jackson-module-kotlin

Open debop opened this issue 3 years ago • 0 comments

Read me

Read this first before creating an issue:

  • do not use this issue tracker to ask questions, instead use one of these channels. Questions will likely be closed without notice.
  • you shall create a feature request only when it is general purpose enough.
  • make sure that the feature is not already

Describe the feature

I want binding row with jackson-databind in vertx-sqlclient-templates with Kotlin data class But DatabindCodec use original ObjectMapper which does not support Kotlin data class

Add some code like this, DatabindCodec can support Kotlin data class

private static void initialize() {
    // automatic register module in classpath  (jackson-module-kotlin, jackson-module-jsr310 ... )
    mapper.findAndRegisterModules()
     
    // mapper configuration ... 
}

Use cases

By jackson-module-kotlin, create data class instance without no-args constructor

data class User(val id:Int, val firstName:String, val lastName: String): Serializable

val users:RowSet<User> = SqlTemplate
    .forQuery(client, "SELECT * FROM user WHERE id=#{id}")
    .mapTo(User::class.java)
    .execute(mapOf("id", 1))
    .await()

Contribution

Who should implement this feature ? are you volunteering for implementing this feature or do you know that is able and willing implement this feature ?

debop avatar Jun 02 '22 06:06 debop