Skip to content

Commit 883969a

Browse files
committed
no-mistakes(review): docs(kotlin): document Jackson jsonb deps, drop stale @serializable claims
1 parent 970072a commit 883969a

2 files changed

Lines changed: 57 additions & 3 deletions

File tree

docs/ports/kotlin.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Idiomatic Kotlin codegen target for Spring-Boot-Kotlin consumers on Exposed +
44
Flyway. The Kotlin port is a **codegen tier built on top of the Java port** — the
55
loader, OMDB persistence engine, render engine, Maven plugin, and conformance
6-
runners are all Java; Kotlin emits idiomatic Kotlin (`@Serializable data class`,
6+
runners are all Java; Kotlin emits idiomatic Kotlin (`data class`,
77
Exposed `Table` objects, extension-fn relationship helpers, Spring `@Configuration`
88
wiring) via KotlinPoet.
99

@@ -39,6 +39,26 @@ Two modules:
3939
<artifactId>exposed-core</artifactId>
4040
<version>${exposed.version}</version>
4141
</dependency>
42+
<!-- Generated typed `field.object @storage:jsonb` / `field.map` columns serialize through a
43+
generated per-package `MetaJsonbMapper.kt` Jackson `ObjectMapper` (no kotlinx-serialization
44+
compiler plugin required). -->
45+
<dependency>
46+
<groupId>com.fasterxml.jackson.core</groupId>
47+
<artifactId>jackson-databind</artifactId>
48+
<version>${jackson.version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.fasterxml.jackson.module</groupId>
52+
<artifactId>jackson-module-kotlin</artifactId>
53+
<version>${jackson.version}</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>com.fasterxml.jackson.datatype</groupId>
57+
<artifactId>jackson-datatype-jsr310</artifactId>
58+
<version>${jackson.version}</version>
59+
</dependency>
60+
<!-- FR-006 output parser + prompt-payload lane; also backs the open-bag
61+
`field.string @dbColumnType:jsonb` → kotlinx `JsonElement` path. -->
4262
<dependency>
4363
<groupId>org.jetbrains.kotlinx</groupId>
4464
<artifactId>kotlinx-serialization-json</artifactId>
@@ -53,7 +73,7 @@ The 9 generators in `codegen-kotlin`:
5373

5474
| Generator | Output | Per |
5575
|---|---|---|
56-
| `KotlinEntityGenerator` | `<Entity>.kt``@Serializable data class` | every `object.entity` + `object.value` |
76+
| `KotlinEntityGenerator` | `<Entity>.kt`Kotlin `data class` (Jackson-compatible; no `@Serializable`) | every `object.entity` + `object.value` |
5777
| `KotlinExposedTableGenerator` | `<Entity>Table.kt` — Exposed `Table` object with PK + FK + `@storage` columns | entities with `source.rdb` |
5878
| `KotlinRelationsGenerator` | `<Entity>Relations.kt` — extension fns for `cardinality=many` query helpers | entities with to-many relationships |
5979
| `KotlinPayloadGenerator` | `<Template>Payload.kt``@Serializable` payload from `@payloadRef` view-object | every `template.prompt` / `template.output` |
@@ -139,7 +159,6 @@ emits:
139159

140160
```kotlin
141161
// generated/acme/blog/Author.kt
142-
@Serializable
143162
data class Author(
144163
val id: Long,
145164
val name: String,

server/java/codegen-kotlin/KNOWN_GAPS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,41 @@ tests; **consumer-side wiring is the consumer's responsibility**, in line
3131
with the cross-port pattern (TS consumers add `zod`; C# uses BCL
3232
`System.Text.Json` — no add needed there; Python consumers add `pydantic`).
3333

34+
## Consumer dependency: Jackson is required for typed jsonb columns
35+
36+
**Status:** consumer-wired, not a code gap — documented here so adopters know what to add.
37+
38+
`KotlinExposedTableGenerator` emits one shared `MetaJsonbMapper.kt` support file per
39+
package that declares at least one typed `field.object @storage:jsonb` (single or
40+
`@isArray` array-of-VO) or `field.map` column. That file holds an
41+
`internal metaJsonbMapper` — a `com.fasterxml.jackson.databind.ObjectMapper` built from
42+
`JsonMapper.builder().addModule(kotlinModule()).addModule(JavaTimeModule())
43+
.disable(WRITE_DATES_AS_TIMESTAMPS)` — that the generated `jsonb()` column codecs
44+
read/write through (a `TypeReference<List<VO>>` captures the array-of-VO generic).
45+
46+
Jackson — not kotlinx — is the codec precisely so the generated entity/value/projection
47+
data classes carry NO `@Serializable` and need NO per-type serializer plumbing: a kotlinx
48+
serializer (`VO.serializer()`) would require the `kotlin("plugin.serialization")`
49+
compiler plugin, and the moment that plugin is on, every VO carrying a
50+
`java.util.UUID` / `java.time.*` / `java.math.BigDecimal` / `java.net.*` field fails to
51+
compile (kotlinx has no serializer for those `java.*` types). Jackson round-trips them
52+
via its kotlin + jsr310 modules with zero per-type wiring. Consumers generating any typed
53+
jsonb/map column must add to their build:
54+
55+
```kotlin
56+
dependencies {
57+
implementation("com.fasterxml.jackson.core:jackson-databind:2.17.x")
58+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.x")
59+
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.x")
60+
}
61+
```
62+
63+
No `kotlin("plugin.serialization")` compiler plugin is needed for this path — the
64+
generated codec is pure runtime Jackson. The separate `field.string @dbColumnType:jsonb`
65+
"open-bag" column stays on the kotlinx lane above (it round-trips through the runtime
66+
`Json.parseToJsonElement` → kotlinx `JsonElement` API, which also needs no compiler
67+
plugin); only the typed object/map jsonb columns pull in Jackson.
68+
3469
## Single-field, `Long`-typed primary keys only
3570

3671
**Status:** assumption baked into Day 1 — same rationale as codegen-spring.

0 commit comments

Comments
 (0)