Skip to content

Commit

Permalink
build: 2.4.0-M3
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Jul 19, 2022
1 parent e775402 commit 3b5afed
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 33 deletions.
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "xyz.cssxsh.mirai"
version = "2.4.0-M2"
version = "2.4.0-M3"

mavenCentralPublish {
useCentralS01()
Expand Down Expand Up @@ -45,7 +45,6 @@ dependencies {

testImplementation(kotlin("test", "1.6.21"))
testImplementation("net.mamoe:mirai-slf4j-bridge:1.2.0")
testImplementation("net.mamoe:mirai-core-utils:2.12.0")
}

mirai {
Expand Down
9 changes: 0 additions & 9 deletions src/main/kotlin/xyz/cssxsh/mirai/hibernate/MiraiHibernate.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import net.mamoe.mirai.console.plugin.jvm.*
import java.io.*
import java.sql.*
import kotlin.io.path.*
import kotlin.reflect.full.*

public interface MiraiHibernateLoader {
/**
Expand Down Expand Up @@ -34,11 +33,7 @@ public interface MiraiHibernateLoader {

public companion object {
@JvmStatic
public operator fun invoke(plugin: JvmPlugin): MiraiHibernateLoader {
return with(plugin::class.findAnnotation<MiraiHibernate>() ?: return Impl(plugin = plugin)) {
loader.objectInstance ?: loader.createInstance()
}
}
public operator fun invoke(plugin: JvmPlugin): MiraiHibernateLoader = Impl(plugin = plugin)

private fun JvmPlugin.database(filename: String): String {
return try {
Expand Down
20 changes: 7 additions & 13 deletions src/main/kotlin/xyz/cssxsh/mirai/hibernate/MiraiHibernatePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ public object MiraiHibernatePlugin : KotlinPlugin(
val configuration = MiraiHibernateConfiguration(plugin = this)

with(configuration) {
if (getProperty("hibernate.connection.provider_class") == "org.hibernate.connection.C3P0ConnectionProvider") {
logger.warning { "发现使用 C3P0ConnectionProvider,将替换为 HikariCPConnectionProvider" }
setProperty(
"hibernate.connection.provider_class",
"org.hibernate.hikaricp.internal.HikariCPConnectionProvider"
)
}
if (getProperty("hibernate.dialect") == "org.sqlite.hibernate.dialect.SQLiteDialect") {
logger.warning { "发现使用 org.sqlite.hibernate.dialect.SQLiteDialect,将替换为 org.hibernate.community.dialect.SQLiteDialect" }
setProperty(
"hibernate.dialect",
"org.hibernate.community.dialect.SQLiteDialect"
)
if (getProperty("hibernate.connection.url").orEmpty().startsWith("jdbc:sqlite")) {
logger.error { "Sqlite 不支持并发, 将替换为 H2Database" }
setProperty("hibernate.connection.url", getProperty("hibernate.connection.url").replace("sqlite", "h2"))
setProperty("hibernate.connection.driver_class", "org.h2.Driver")
setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect")
setProperty("hibernate.hikari.minimumIdle", "10")
setProperty("hibernate.hikari.maximumPoolSize", "10")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public data class FaceRecord(
public val height: Int,
@Column(name = "width", nullable = false)
public val width: Int,
@Column(name = "disable", nullable = false)
@Column(name = "disable", nullable = false, updatable = false)
@org.hibernate.annotations.ColumnDefault("False")
public val disable: Boolean = false
) : java.io.Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ abstract class DatabaseTest {
}

@Test
fun tag() {
fun join() {
factory.openSession().use { session ->
val face = session.withCriteria<FaceRecord> { criteria ->
val root = criteria.from<FaceRecord>()
Expand All @@ -128,7 +128,7 @@ abstract class DatabaseTest {
session.merge(FaceTagRecord(md5 = face.md5, tag = "test"))
session.transaction.commit()

println(face.tags)
logger.info(face.tags.toString())

session.transaction.begin()
session.merge(face.copy(disable = true))
Expand Down

0 comments on commit 3b5afed

Please sign in to comment.