Skip to content

Fix TestInsert for Kotlin and Java#175

Merged
oyvindberg merged 2 commits intomainfrom
fix-testinsert-kotlin-java
Dec 27, 2025
Merged

Fix TestInsert for Kotlin and Java#175
oyvindberg merged 2 commits intomainfrom
fix-testinsert-kotlin-java

Conversation

@oyvindberg
Copy link
Copy Markdown
Collaborator

Summary

TestInsert now works properly for all three JVM languages:

  • Kotlin: Fixed by adding default parameter values for Defaulted fields
  • Java: Implemented fluent Inserter<U,R> pattern since Java lacks default parameters

Java Usage

// Simple insert
var row = testInsert.personBusinessentity().insert(c);

// With required parameters
var person = testInsert.personPerson(entityId, "EM", firstName).insert(c);

// Customize with .with() before inserting
var product = testInsert.productionProduct(...)
    .with(row -> row.withName(new Name("Custom")))
    .insert(c);

Changes

  • Add Inserter<U,R> interface in foundations-jdbc with of(), with(), insert()
  • Generate Inserter-based methods for Java, default parameters for Kotlin/Scala
  • Fix Java code generation in ComputedTestInserts:
    • Use jvm.New() for proper constructor calls
    • Fully qualify Defaulted.UseDefault
    • Use string constructors for Int2Vector/Vector
    • Language-native list access for enum selection
  • Update Java tests to use new API
  • Update documentation with Java examples

Test plan

  • All Java tests pass
  • All Scala tests pass
  • All Kotlin tests pass
  • Regenerated code for all databases (PostgreSQL, MariaDB, DuckDB, Oracle, SQL Server)

🤖 Generated with Claude Code

oyvindberg and others added 2 commits December 27, 2025 15:16
TestInsert now works properly for all three JVM languages:

- **Kotlin**: Fixed by adding default parameter values for Defaulted fields
- **Java**: Implemented fluent `Inserter<U,R>` pattern since Java lacks default parameters

## Java Usage

```java
// Simple insert
var row = testInsert.personBusinessentity().insert(c);

// With required parameters
var person = testInsert.personPerson(entityId, "EM", firstName).insert(c);

// Customize with .with() before inserting
var product = testInsert.productionProduct(...)
    .with(row -> row.withName(new Name("Custom")))
    .insert(c);
```

## Changes

- Add `Inserter<U,R>` interface in foundations-jdbc with `of()`, `with()`, `insert()`
- Generate Inserter-based methods for Java, default parameters for Kotlin/Scala
- Fix Java code generation in ComputedTestInserts:
  - Use jvm.New() for proper constructor calls
  - Fully qualify Defaulted.UseDefault
  - Use string constructors for Int2Vector/Vector
  - Language-native list access for enum selection
- Update Java tests to use new API
- Update documentation with Java examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@oyvindberg oyvindberg merged commit 102258a into main Dec 27, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant