Fix Only_full_group_by_sql_error

Recently, I encountered sql state 42000 error in a spring boot application while moving from MySQL version 5.6 to 8.0. After inspecting stack trace and some googling, I got to know that few default configurations have changed in MySQL 8.0 (as expected 😃 ). This caused our poorly written queries to fail during migration. Background Lets look at sample query using spring-data jpa to gather some analytics by aggregating data about a customer ordering products...

Kotlin Enum

Let’s have a look at enums in kotlin. Unlike Java, where enum is a Type; in Kotlin, enums are classes Defining an enum 1 2 3 enum class Direction { NORTH, SOUTH, WEST, EAST } Defining an enum with a variable 1 2 3 enum class Direction(val shortName: Char) { NORTH('N'), SOUTH('S'), WEST('W'), EAST('E') } Template Method pattern in Enum 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 enum class Direction(val shortName: Char) { NORTH('N') { override fun move() = "Moving in North Direction" }, SOUTH('S') { override fun move() = "Moving in South Direction" }, WEST('W'){ override fun move() = "Moving in West Direction" }, EAST('E'){ override fun move() = "Moving in East Direction" }; abstract fun move(): String } Companion methods in enum 1 2 3 4 5 6 7 enum class Direction(val shortName: String) { NORTH("N"), SOUTH("S"), WEST("W"), EAST("E"); companion object { fun valueOfIgnoreCase(name: String) = valueOf(name....

Springdoc OpenApi3 Swagger

When working as a backend engineer, it is essential to document the REST APIs. It also helps in providing a UI(swagger-ui) to test the REST calls. Let us try to integrate springdoc-openapi to provide swagger documentation for a spring boot project using spring-security(OAuth2). Add the dependencies to build.gradle 1 2 3 implementation("org.springdoc:springdoc-openapi-ui:1.6.8") implementation("org.springdoc:springdoc-openapi-security:1.6.8") implementation("org.springdoc:springdoc-openapi-kotlin:1.6.8") Kotlin code example The following example showcases spring configuration to create OpenAPI bean which supports two authentication mechanism:...

JedisDataException ERR unknown command CONFIG

Error While trying to setup Azure Cache for Redis as spring session store, I encountered following exception: .JedisDataException: ERR unknown command CONFIG, with args beginning with: get, notify-keyspace-events": 1, Fix Found the solution in spring-session-gh-issue Kotlin 1 2 3 4 5 6 7 8 9 10 @Configuration class HttpSessionConfig() { companion object { // another solution could be to enable notify-keyspace-events for redis @Bean fun configureRedisAction(): ConfigureRedisAction { return ConfigureRedisAction....