Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

org.komapper:komapper-dialect-mysql-jdbc

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

org.komapper:komapper-dialect-mysql-jdbc

Komapper MySQL Dialect for JDBC

  • 3.1.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Komapper: Kotlin ORM for JDBC and R2DBC

Build Twitter Slack Maven Central

Komapper is an ORM library for server-side Kotlin.

For more documentation, go to our site:

Features

Highlighted

  • Support for both JDBC and R2DBC
  • Code generation at compile-time using Kotlin Symbol Processing API
  • Immutable and composable queries
  • Support for Kotlin value classes
  • Easy Spring Boot integration

Experimental

  • Quarkus integration
  • Transaction management using context receivers

Prerequisite

  • Kotlin 1.8.22 or later
  • JRE 11 or later
  • Gradle 6.8.3 or later

Supported Databases

Komapper is tested with the following databases:

DatabaseversionJDBC supportR2DBC support
H2 Database2.3.230vv
MariaDB10.6.3vv
MySQL v5.x5.7.44vv
MySQL v8.x8.0.25vv
Oracle Database XE18.4.0vv
PostgreSQL12.9vv
SQL Server2019v(unstable)

Supported connectivity types:

  • JDBC 4.3
  • R2DBC 1.0.0

Installation

Add the following code to the Gradle build script (gradle.build.kts).

plugins {
    kotlin("jvm") version "2.0.20"
    id("com.google.devtools.ksp") version "2.0.20-1.0.25"
}

val komapperVersion = "3.1.0"

dependencies {
    platform("org.komapper:komapper-platform:$komapperVersion").let {
        implementation(it)
        ksp(it)
    }
    implementation("org.komapper:komapper-starter-jdbc")
    implementation("org.komapper:komapper-dialect-h2-jdbc")
    ksp("org.komapper:komapper-processor")
}

See also Quickstart for more details:

Sample code

To get complete code, go to our example repository.

Entity class definition

@KomapperEntity
data class Address(
    @KomapperId
    @KomapperAutoIncrement
    @KomapperColumn(name = "ADDRESS_ID")
    val id: Int = 0,
    val street: String,
    @KomapperVersion
    val version: Int = 0,
    @KomapperCreatedAt
    val createdAt: LocalDateTime? = null,
    @KomapperUpdatedAt
    val updatedAt: LocalDateTime? = null,
)

Connecting with JDBC

fun main() {
    // create a Database instance
    val db = JdbcDatabase("jdbc:h2:mem:example;DB_CLOSE_DELAY=-1")

    // get a metamodel
    val a = Meta.address

    // execute simple operations in a transaction
    db.withTransaction {
        // create a schema
        db.runQuery {
            QueryDsl.create(a)
        }

        // INSERT
        val newAddress = db.runQuery {
            QueryDsl.insert(a).single(Address(street = "street A"))
        }

        // SELECT
        val address = db.runQuery {
            QueryDsl.from(a).where { a.id eq newAddress.id }.first()
        }
    }
}

Connecting with R2DBC

suspend fun main() {
    // create a Database instance
    val db = R2dbcDatabase("r2dbc:h2:mem:///example;DB_CLOSE_DELAY=-1")

    // get a metamodel
    val a = Meta.address

    // execute simple operations in a transaction
    db.withTransaction {
        // create a schema
        db.runQuery {
            QueryDsl.create(a)
        }

        // INSERT
        val newAddress = db.runQuery {
            QueryDsl.insert(a).single(Address(street = "street A"))
        }

        // SELECT
        val address = db.runQuery {
            QueryDsl.from(a).where { a.id eq newAddress.id }.first()
        }
    }
}

Design Policy

See DESIGN_DOC for the design policy of this project.

Compatibility Matrix

Kotlin and KSP versionKomapper versionKSP2 support?JRE min versionGradle min version
1.8.22-1.0.111.16.1No116.8.3
1.9.24-1.0.201.18.1 - 2.1.0No116.8.3
2.0.0-1.0.251.18.1 - 3.0.xYes117.6.4

Compatibility testing is performed in the komapper/compatibility-test repository.

Backers

If you use Komapper in your project or enterprise and would like to support ongoing development, please consider becoming a backer. [Become a backer]

Our top backers are shown below!

FAQs

Package last updated on 05 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc