Playground for support of common KMP types in popular JVM frameworks or APIs, like JPA, Spring Boot, Elide and SQLDelight.
Supported KMP libraries:
Releases are available from Maven Central. Snapshots are available from Sonatype's OSS repository:
// For snapshots, optional
maven("https://oss.sonatype.org/content/repositories/snapshots/")
The following Gradle dependency adds JPA Attribute Converters for supported KMP types:
implementation("com.github.manosbatsis.kmp.converters:kmp-converters-jpa:$kmpConvertersVersion")
The converters can be found in the com.github.manosbatsis.kmp.converters.jpa
package.
Note that JPA does not apply Attribute Converters on @Id
annotated members. If you need to use one of the supported KMP types
as an identifier, you can work around the JPA spec limitation in three steps:
- Wrap the converted type within an
Embeddable
type - Use the wrapper as the id type
- Annotate the id
@EmbeddedId
For example, suppose you want to use com.benasher44.uuid.Uuid
as an identifier:
@Embeddable
class UuidId {
@Column(name = "ID", nullable = false)
@Convert(converter = UuidAttributeConverter::class)
private var id: Uuid? = null
}
// In your entity
@Entity
class MyEntity(
@EmbeddedId
private var pk: UuidId? = null
)
The following starter configures the JPA Attribute Converters described above:
implementation("com.github.manosbatsis.kmp.converters:kmp-converters-springboot-starter:$kmpConvertersVersion")
The following dependencies add JPA Attribute Converters (as described above) and Serde implementations for supported KMP types:
implementation("com.github.manosbatsis.kmp.converters:kmp-converters-jpa:$kmpConvertersVersion")
implementation("com.github.manosbatsis.kmp.converters:kmp-converters-elide:$kmpConvertersVersion")
The following starter configures both JPA and Serde converters described in previous sections:
implementation("com.github.manosbatsis.kmp.converters:kmp-converters-elide-starter:$kmpConvertersVersion")
The following Gradle dependency adds custom column types for supported KMP types:
implementation("com.github.manosbatsis.kmp.converters:kmp-converters-sqldelight:$kmpConvertersVersion")
The converters reside in the com.github.manosbatsis.kmp.converters.sqldelight
package.