mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
#2692 - [querybean generation] Compile error, incorrect generation with nested inner class/record @Embeddable and @IdClass
This commit is contained in:
1 parent
b7d6374370
commit
9dea51b7a0
13 files changed
+316
-68
No files matched your search
@@ -0,0 +1,20 @@
|
||||
package io.ebean.querybean.generator
|
||||
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class UtilTest {
|
||||
|
||||
@Test
|
||||
fun packageOf() {
|
||||
Assertions.assertEquals(Util.packageOf(true, "com.example.Foo.Bar"), "com.example")
|
||||
Assertions.assertEquals(Util.packageOf(false, "com.example.other.foo.Bar"), "com.example.other.foo")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shortName() {
|
||||
Assertions.assertEquals(Util.shortName(true, "com.example.Foo.Bar"), "Foo.Bar")
|
||||
Assertions.assertEquals(Util.shortName(false, "com.example.foo.Bar"), "Bar")
|
||||
Assertions.assertEquals(Util.shortName(false, "Bar"), "Bar")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.example.domain
|
||||
|
||||
import javax.persistence.*
|
||||
|
||||
@Entity
|
||||
@Table(name = "t_inner")
|
||||
@IdClass(MyKotInner.Mid::class)
|
||||
class MyKotInner {
|
||||
|
||||
@Id
|
||||
var one: String = "0"
|
||||
@Id
|
||||
var two: String = "0"
|
||||
|
||||
var description: String? = null
|
||||
|
||||
@Embeddable
|
||||
data class Mid(val one: String, val two: String)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.example.otherpackage
|
||||
|
||||
import io.ebean.DB
|
||||
import org.assertj.core.api.AssertionsForInterfaceTypes.assertThat
|
||||
import org.example.domain.MyKotInner
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class InnerTest {
|
||||
|
||||
@Test
|
||||
fun split_normal() {
|
||||
val my = MyKotInner()
|
||||
my.one = "a"
|
||||
my.two = "b"
|
||||
my.description = "desc"
|
||||
DB.save(my)
|
||||
|
||||
val myId = MyKotInner.Mid("a", "b")
|
||||
|
||||
val found = DB.find(MyKotInner::class.java, myId)
|
||||
assertThat(found).isNotNull
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
ebean-version: 141
|
||||
@@ -0,0 +1,9 @@
|
||||
ebean.ddl.generate=true
|
||||
ebean.ddl.run=true
|
||||
#datasource.default=h2
|
||||
|
||||
datasource.db.username=sa
|
||||
datasource.db.password=
|
||||
datasource.db.url=jdbc:h2:mem:testKotlin
|
||||
|
||||
|
||||
Reference in new issue
Block a user