Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ouyangem opened this issue Oct 21, 2024 · 1 comment · Fixed by #3555
Closed

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

ouyangem opened this issue Oct 21, 2024 · 1 comment · Fixed by #3555
Assignees
Labels
Milestone

Comments

@ouyangem
Copy link

ouyangem commented Oct 21, 2024

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
Copy link
Author

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

@rbygrave rbygrave linked a pull request Feb 9, 2025 that will close this issue
@rbygrave rbygrave self-assigned this Feb 9, 2025
@rbygrave rbygrave added the bug label Feb 9, 2025
@rbygrave rbygrave added this to the 14.8.3 milestone Feb 9, 2025
rbygrave added a commit that referenced this issue Feb 10, 2025
…-gen-DbMap

#3503 - Fix kotlin-querybean-generator for use of @DbMap
@rbygrave rbygrave modified the milestones: 14.8.3, 14.9.0 Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants