更新日志

Kronos 严格遵循 Semantic Versioning 2.0.0 语义化版本规范。

📝 更新日志

0.4.0

升级说明

0.3.1

升级说明

0.3.0

升级说明

0.2.4

升级说明

0.2.3

0.2.2

0.2.1

0.2.0

0.2.0 包含源码和二进制不兼容的公开 API 变更。升级依赖后需要重新编译项目,并按下面的迁移说明更新调用点和自定义扩展。

破坏性 API 变更

查询终结方法统一使用集合转换和单行读取语义:

0.1.x0.2.0
query()toMapList() / toList<Map<String, Any?>>()
queryList<T>()toList<T>()
queryMap()toMap() / first<Map<String, Any?>>()
queryMapOrNull()toMapOrNull() / firstOrNull<Map<String, Any?>>() / first<Map<String, Any?>?>()
queryOne<T>()first<T>()
queryOneOrNull<T>()firstOrNull<T>() / first<T?>()
PagedClause.query()PagedClause.toMapList()
PagedClause.queryList()PagedClause.toList()

toMapList()、toMap() 和 toMapOrNull() 是对应泛型写法的便捷方法;一般情况下,firstOrNull<T>() 也等价于 first<T?>()。Map 查询结果类型由 Map<String, Any> 改为 Map<String, Any?>,被选中的 SQL NULL 会保留在结果中。QueryType 同步精简为 ToMapList、ToList、ToMap 和 First;使用查询事件回调的项目需要更新枚举分支。原生 SQL 扩展改由 com.kotlinorm.database.SqlExecutor 提供,原 SqlHandler 对象已删除。

内置 JDBC wrapper 已统一为 KronosJdbcWrapper。从更早版本升级、仍在使用旧 KronosBasicWrapper 的项目需要替换类名和包名:

// 旧 API
import com.kotlinorm.KronosBasicWrapper
val wrapper = KronosBasicWrapper(dataSource)

// 0.2.0
import com.kotlinorm.wrappers.KronosJdbcWrapper
val wrapper = KronosJdbcWrapper(dataSource)

自定义 KronosDataSourceWrapper 实现需要移除 forList、forMap、forObject,改为实现以下两个查询入口;结果映射目标从 task.targetType 读取:

override fun toList(task: KAtomicQueryTask): List<Any?>
override fun first(task: KAtomicQueryTask): Any?

查询任务和类型转换链路改用完整 Kotlin KType:

功能与修复

0.1.2

0.1.1

0.1.0

0.0.7

0.0.6

0.0.5

0.0.4

0.0.3

0.0.2

0.0.1

使用快照版本

快照版本提供下一稳定版之前的功能,可用于开发和验证。

Maven Central Snapshots

在插件和依赖解析中加入快照仓库,再使用快照坐标。

gradle(groovy)

// settings.gradle
pluginManagement {
    repositories {
        mavenCentral()
        maven {
            url "https://central.sonatype.com/repository/maven-snapshots/"
        }
    }
}

// build.gradle
repositories {
    mavenCentral()
    maven {
        url "https://central.sonatype.com/repository/maven-snapshots/"
    }
}

plugins {
    id 'com.kotlinorm.kronos-gradle-plugin' version '0.4.1-SNAPSHOT'
}

dependencies {
    implementation "com.kotlinorm:kronos-core:0.4.1-SNAPSHOT"
    implementation "com.kotlinorm:kronos-jdbc-wrapper:0.4.1-SNAPSHOT"
}

gradle(kts)

// settings.gradle.kts
pluginManagement {
    repositories {
        mavenCentral()
        maven {
            name = "Maven Central Snapshots"
            url = uri("https://central.sonatype.com/repository/maven-snapshots/")
        }
    }
}

// build.gradle.kts
repositories {
    mavenCentral()
    maven {
        name = "Maven Central Snapshots"
        url = uri("https://central.sonatype.com/repository/maven-snapshots/")
    }
}

plugins {
    id("com.kotlinorm.kronos-gradle-plugin") version "0.4.1-SNAPSHOT"
}

dependencies {
    implementation("com.kotlinorm:kronos-core:0.4.1-SNAPSHOT")
    implementation("com.kotlinorm:kronos-jdbc-wrapper:0.4.1-SNAPSHOT")
}

maven

<project>
  <properties>
    <kronos.version>0.4.1-SNAPSHOT</kronos.version>
  </properties>

  <repositories>
    <repository>
      <id>maven-central-snapshots</id>
      <url>https://central.sonatype.com/repository/maven-snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>com.kotlinorm</groupId>
      <artifactId>kronos-core</artifactId>
      <version>${kronos.version}</version>
    </dependency>
    <dependency>
      <groupId>com.kotlinorm</groupId>
      <artifactId>kronos-jdbc-wrapper</artifactId>
      <version>${kronos.version}</version>
    </dependency>
  </dependencies>

  <pluginRepositories>
    <pluginRepository>
      <id>maven-central-snapshots</id>
      <url>https://central.sonatype.com/repository/maven-snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <plugins>
      <plugin>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <compilerPlugins>
            <plugin>all-open</plugin>
            <plugin>kronos-maven-plugin</plugin>
          </compilerPlugins>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-allopen</artifactId>
            <version>${kotlin.version}</version>
          </dependency>
          <dependency>
            <groupId>com.kotlinorm</groupId>
            <artifactId>kronos-maven-plugin</artifactId>
            <version>${kronos.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</project>

Kotlin 版本兼容性

Kronos 版本支持的 Kotlin 版本说明
0.4.02.4.21Kotlin Multiplatform:JVM、Android/JVM 和 Kotlin/Native
0.3.12.4.0+H2 和达梦方言、JDBC 连接与行映射,以及 Kotlin String 和跨方言 SQL 函数
0.3.02.4.0+支持 Android/JVM SQLite,见 Android SQLite 指南
0.2.0 - 0.2.42.4.0+Kotlin 2.4.0 版本线
0.1.22.4.0+修复表结构同步边缘场景并扩充跨数据库集成测试
0.1.12.4.0+补充投影文档与发版自动化改进
0.1.02.3.0+基于 Kotlin 2.3.0 的正式发布版本
0.0.72.3.0+在 0.0.7 中升级 Gradle 和 Kotlin
0.0.62.2.21+添加 kotlin.time.Instant 支持
0.0.2 - 0.0.52.2.0+2.2.21 升级前的早期开发版本
0.0.12.1.0+初始公开发布版本线