ebean-orm / ebean

Ebean ORM
https://ebean.io
Apache License 2.0
1.47k stars 260 forks source link

kotlin-querybean-generator generated wrong kotlin code for "Map<String, Any>" #3503

Open ouyangem opened 1 month ago

ouyangem commented 1 month ago

Environment

Java 11, Kotlin 1.7.22, Gradle 8.5 ebean 14.7.0 | 15.7.0, h2database :2.3.232

plugins {
  id("idea")
  kotlin ("jvm") version "1.7.22"
  kotlin ("kapt") version "1.7.22"
  id("io.ebean") version "15.7.0"
  id("com.github.johnrengelman.shadow") version "7.1.2"
  application
}
dependencies {
  implementation("com.h2database:h2:2.3.232")
  implementation("io.ebean:ebean-h2:15.7.0")
  testImplementation("io.ebean:ebean-test:15.7.0")
  kapt("io.ebean:kotlin-querybean-generator:15.7.0")
}

Expected behavior

Generate lateinit var params: PScalar<QDevice, Map<String,Any>>

Actual behavior

Path: build/generated/source/kaptKotlin/main/com/foo/bar/domain/query/QDevice.kt

package com.foo.bar.domain.query;

// Strange "import" text
import ?;
//...
import extends;
import java.lang.Object;
// Some things are omitted
  lateinit var params: PScalar<QDevice, Map<String,? extends Object>>

Steps to reproduce

package com.foo.bar.domain

import io.ebean.annotation.DbMap
import jakarta.persistence.*

@Entity
@Table(name = "devices")
class Device(@Column(length = 50, unique = true) val name: String) {
  @Id
  var id: Int = 0

  @DbMap(length = 800)
  var params: Map<String, Any> = mapOf()
}

Screenshot

20241022001255

ouyangem commented 1 month ago

After change this

  @DbMap(length = 800)
  var params: Map<String, Any> = mapOf()

To this

  @DbJson(storage = DbJsonType.VARCHAR, length = 800)
  var params: Map<String, Any> = mapOf()

Everything works fine