diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java
index 3412ff72..5c68ccb6 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java
@@ -91,17 +91,17 @@ public class FlexGlobalConfig {
/**
* 默认的逻辑删除字段,允许设置 {@code null} 忽略匹配。
*/
- private String logicDeleteColumn = "del_flag";
+ private String logicDeleteColumn;
/**
* 默认的多租户字段,允许设置 {@code null} 忽略匹配。
*/
- private String tenantColumn = "tenant_id";
+ private String tenantColumn;
/**
* 默认的乐观锁字段,允许设置 {@code null} 忽略匹配。
*/
- private String versionColumn = "version";
+ private String versionColumn;
public boolean isPrintBanner() {
return printBanner;
@@ -323,7 +323,7 @@ public class FlexGlobalConfig {
}
public void setNormalValueOfLogicDelete(Object normalValueOfLogicDelete) {
- FlexAssert.notNull(normalValueOfLogicDelete,"normalValueOfLogicDelete");
+ FlexAssert.notNull(normalValueOfLogicDelete, "normalValueOfLogicDelete");
this.normalValueOfLogicDelete = normalValueOfLogicDelete;
}
@@ -332,7 +332,7 @@ public class FlexGlobalConfig {
}
public void setDeletedValueOfLogicDelete(Object deletedValueOfLogicDelete) {
- FlexAssert.notNull(deletedValueOfLogicDelete,"deletedValueOfLogicDelete");
+ FlexAssert.notNull(deletedValueOfLogicDelete, "deletedValueOfLogicDelete");
this.deletedValueOfLogicDelete = deletedValueOfLogicDelete;
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java
index 05a04b39..18d351be 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java
@@ -150,7 +150,17 @@ public class TableInfo {
}
public void setTableName(String tableName) {
- this.tableName = tableName;
+ int indexOf = tableName.indexOf(".");
+ if (indexOf > 0) {
+ if (StringUtil.isBlank(schema)) {
+ this.schema = tableName.substring(0, indexOf);
+ this.tableName = tableName.substring(indexOf + 1);
+ } else {
+ this.tableName = tableName;
+ }
+ } else {
+ this.tableName = tableName;
+ }
}
public Class> getEntityClass() {
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java
index de78dc77..f205ea42 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java
@@ -134,8 +134,8 @@ public class TableInfoFactory {
//初始化表名
Table table = entityClass.getAnnotation(Table.class);
if (table != null) {
- tableInfo.setTableName(table.value());
tableInfo.setSchema(table.schema());
+ tableInfo.setTableName(table.value());
tableInfo.setCamelToUnderline(table.camelToUnderline());
if (table.onInsert().length > 0) {
diff --git a/mybatis-flex-kotlin/pom.xml b/mybatis-flex-kotlin/pom.xml
deleted file mode 100755
index 830fa4c0..00000000
--- a/mybatis-flex-kotlin/pom.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *
- * http://www.apache.org/licenses/LICENSE-2.0 - *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.kotlin.db
-
-import java.util.NoSuchElementException
-import kotlin.properties.ReadWriteProperty
-import kotlin.reflect.KProperty
-
-/**
- * 数据库配置对象,暂时未启用
- * @author 卡莫sama(yuanjiashuai)
- * @date 2023/8/7
- */
-object DbConfig {
-
- var url: String by IfNullVar { "" }
- var username: String by IfNullVar { "" }
- var password: String by IfNullVar { "" }
-
-
-}
-
-class IfNullVar
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.kotlin.extensions.db
-
-import com.mybatisflex.core.mybatis.Mappers
-import com.mybatisflex.core.query.QueryColumn
-import com.mybatisflex.core.query.QueryCondition
-import com.mybatisflex.core.row.Db.selectListByQuery
-import com.mybatisflex.core.row.Db.selectOneByQuery
-import com.mybatisflex.core.row.Row
-import com.mybatisflex.core.table.TableDef
-import com.mybatisflex.core.table.TableInfoFactory
-import com.mybatisflex.kotlin.extensions.model.filter
-import com.mybatisflex.kotlin.extensions.model.toEntities
-import com.mybatisflex.kotlin.scope.QueryScope
-import com.mybatisflex.kotlin.scope.queryScope
-
-
-/*
- * 数据库简单操作扩展
- * @author 卡莫sama(yuanjiashuai)
- */
-
-inline fun
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.kotlin.extensions.mapper
-
-import com.mybatisflex.core.BaseMapper
-import com.mybatisflex.core.query.QueryCondition
-import com.mybatisflex.kotlin.scope.QueryScope
-import com.mybatisflex.kotlin.scope.queryScope
-/*
- * 映射器操作扩展
- * @author 卡莫sama(yuanjiashuai)
- */
-fun
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.kotlin.extensions.model
-
-import com.mybatisflex.core.activerecord.Model
-import com.mybatisflex.core.mybatis.Mappers
-import com.mybatisflex.core.query.QueryColumn
-import com.mybatisflex.core.query.QueryCondition
-import com.mybatisflex.core.row.Db.*
-import com.mybatisflex.core.row.Row
-import com.mybatisflex.core.row.RowUtil
-import com.mybatisflex.core.table.TableDef
-import com.mybatisflex.core.table.TableInfoFactory
-import com.mybatisflex.core.util.SqlUtil
-import com.mybatisflex.kotlin.extensions.db.*
-import com.mybatisflex.kotlin.scope.QueryScope
-import java.io.Serializable
-
-/*
- * 实体操作扩展
- * @author 卡莫sama(yuanjiashuai)
- */
-
-infix fun
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.kotlin.extensions.sql
-
-import com.mybatisflex.core.query.*
-import java.util.function.Consumer
-
-/*
- * sql操作扩展
- * @author 卡莫sama(yuanjiashuai)
- * @date 2023/8/7
- */
-
-
-//logic------
-inline fun `if`(test: Boolean, block: () -> QueryCondition): QueryCondition =
- if (test) block() else QueryCondition.createEmpty()
-
-inline fun QueryCondition.andIf(test: Boolean, block: () -> QueryCondition): QueryCondition =
- if (test) this.and(block()) else this
-
-inline fun QueryCondition.orIf(test: Boolean, block: () -> QueryCondition): QueryCondition =
- if (test) this.or(block()) else this
-
-infix fun QueryCondition.and(other: QueryCondition): QueryCondition = this.and(other)
-
-infix fun QueryCondition.or(other: QueryCondition): QueryCondition = this.or(other)
-
-//Comparable------
-infix fun QueryColumn.like(value: String): QueryCondition = this.like(value)
-
-infix fun QueryColumn.eq(value: Any?): QueryCondition = this.eq(value)
-
-infix fun QueryColumn.ne(value: Any?): QueryCondition = this.ne(value)
-
-infix fun QueryColumn.`=`(value: Any?): QueryCondition = this.eq(value)
-
-infix fun QueryColumn.`!=`(value: Any?): QueryCondition = this.ne(value)
-
-infix fun QueryColumn.gt(value: Any?): QueryCondition = this.gt(value)
-
-infix fun QueryColumn.ge(value: Any?): QueryCondition = this.ge(value)
-
-infix fun QueryColumn.le(value: Any?): QueryCondition = this.le(value)
-
-infix fun QueryColumn.lt(value: Any?): QueryCondition = this.lt(value)
-
-//range-----
-infix fun QueryColumn.between(pair: Pair
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import com.mybatisflex.core.MybatisFlexBootstrap
-import javax.sql.DataSource
-
-class BootstrapScope(private val instant: MybatisFlexBootstrap = MybatisFlexBootstrap.getInstance()) {
-
- fun dataSources(dataSourceScope: DataSourceScope.() -> Unit) =
- dataSourceScope(DataSourceScope(instant))
-
-
- operator fun
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.kotlin.scope
-
-import com.mybatisflex.core.query.QueryColumn
-import com.mybatisflex.core.query.QueryCondition
-import com.mybatisflex.core.query.QueryWrapper
-import com.mybatisflex.core.table.TableDef
-/**
- * 查询作用域
- * @author 卡莫sama(yuanjiashuai)
- * @date 2023/8/7
- */
-class QueryScope :QueryWrapper() {
- companion object CurrentQueryScope : ThreadLocal
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.test
-
-import com.mybatisflex.core.mybatis.FlexConfiguration
-import com.mybatisflex.spring.FlexSqlSessionFactoryBean
-import org.apache.ibatis.logging.stdout.StdOutImpl
-import org.apache.ibatis.session.SqlSessionFactory
-import org.mybatis.spring.SqlSessionFactoryBean
-import org.mybatis.spring.annotation.MapperScan
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.Configuration
-import org.springframework.context.event.ContextStartedEvent
-import org.springframework.context.event.EventListener
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType
-import javax.sql.DataSource
-
-@Configuration
-@MapperScan("com.mybatisflex.test.mapper")
-open class AppConfig {
-
-
- @Bean
- open fun dataSource(): DataSource? {
- return EmbeddedDatabaseBuilder()
- .setType(EmbeddedDatabaseType.H2)
- .addScript("schema.sql")
- .addScript("data-kt.sql")
- .build()
- }
-
- @Bean
- open fun sqlSessionFactory(dataSource: DataSource): SqlSessionFactory? {
- val factoryBean: SqlSessionFactoryBean = FlexSqlSessionFactoryBean()
- factoryBean.setDataSource(dataSource)
- val configuration = FlexConfiguration()
- configuration.logImpl = StdOutImpl::class.java
- factoryBean.setConfiguration(configuration)
- return factoryBean.getObject()
- }
-
- @EventListener(classes = [ContextStartedEvent::class])
- open fun handleContextStartedEvent() {
- println("handleContextStartedEvent listener invoked!")
- }
-
-
-
-}
-
-
diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/mapper/AccountMapper.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/mapper/AccountMapper.kt
deleted file mode 100755
index 571f6cec..00000000
--- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/kotlin/com/mybatisflex/test/mapper/AccountMapper.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.mybatisflex.test.mapper
-
-import com.mybatisflex.core.BaseMapper
-import com.mybatisflex.kotlin.extensions.mapper.queryList
-import com.mybatisflex.kotlin.extensions.sql.*
-import com.mybatisflex.test.model.Account
-
-
-@JvmDefaultWithCompatibility
-interface AccountMapper : BaseMapper
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.test.model
-
-import com.mybatisflex.annotation.Id
-import com.mybatisflex.annotation.NoneListener
-import com.mybatisflex.annotation.Table
-import com.mybatisflex.core.activerecord.Model
-import com.mybatisflex.test.model.table.AccountTableDef
-import java.util.*
-/**
- * 测试用数据类(最好不要写成data class,否则没有无参构造需要与数据库字段数据顺序一致)
- * @author 卡莫sama(yuanjiashuai)
- * @date 2023/8/7
- */
-@Table(value = "tb_account", onUpdate = [NoneListener::class], onSet = [AccountOnSetListener::class])
-data class Account(
- @Id var id: Int,
- var userName: String?,
- var age: Int?,
- var birthday: Date?,
-) : Model
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.test.model
-
-import com.mybatisflex.annotation.SetListener
-
-
-class AccountOnSetListener : SetListener {
- override fun onSet(entity: Any, property: String, value: Any): Any {
- println(">>>>>>> property: $property value:$value")
- return value
- }
-}
-
diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/data-kt.sql b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/data-kt.sql
deleted file mode 100755
index 959cc26e..00000000
--- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/data-kt.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-INSERT INTO tb_account(id, user_name, age, birthday)
-VALUES (1, '张三', 18, '2020-01-11'),
- (2, '李四', 19, '2021-03-21');
diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/mybatis-flex.properties b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/mybatis-flex.properties
deleted file mode 100755
index 929568bf..00000000
--- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/mybatis-flex.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-processor.mappersGenerateEnable=false
-processor.tablesNameStyle=lowerCase
-processor.tablesDefSuffix=Def
-processor.allInTables=true
diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/schema.sql b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/schema.sql
deleted file mode 100755
index 161937d0..00000000
--- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/main/resources/schema.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE IF NOT EXISTS `tb_account`
-(
- `id` INTEGER ,
- `user_name` VARCHAR(100) NOT NULL,
- `age` INTEGER,
- `birthday` DATETIME
-);
diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinSpringTest.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinSpringTest.kt
deleted file mode 100755
index 1ba41622..00000000
--- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinSpringTest.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.test
-
-import com.mybatisflex.test.mapper.AccountMapper
-import org.assertj.core.api.WithAssertions
-import org.junit.runner.RunWith
-
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
-import kotlin.test.Test
-
-
-@RunWith(SpringJUnit4ClassRunner::class)
-@ContextConfiguration(classes = [AppConfig::class])
-class KotlinSpringTest : WithAssertions {
- @Autowired
- lateinit var accountMapper: AccountMapper
-
- @Test
- fun testSelectByQuery() {
- val accounts = accountMapper.findByAge(18,2)
- accounts.forEach(::println)
- }
-
-
-}
diff --git a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinTest.kt b/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinTest.kt
deleted file mode 100644
index 075666f5..00000000
--- a/mybatis-flex-test/mybatis-flex-spring-kotlin-test/src/test/kotlin/com/mybatisflex/test/KotlinTest.kt
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mybatisflex.test
-
-import com.mybatisflex.core.FlexConsts
-import com.mybatisflex.core.activerecord.Model
-import com.mybatisflex.core.audit.AuditManager
-import com.mybatisflex.core.audit.ConsoleMessageCollector
-import com.mybatisflex.kotlin.extensions.db.filter
-import com.mybatisflex.kotlin.extensions.db.mapper
-import com.mybatisflex.kotlin.extensions.db.query
-import com.mybatisflex.kotlin.extensions.model.*
-import com.mybatisflex.kotlin.extensions.sql.*
-import com.mybatisflex.kotlin.scope.buildBootstrap
-import com.mybatisflex.test.mapper.AccountMapper
-import com.mybatisflex.test.model.Account
-import com.mybatisflex.test.model.table.AccountTableDef.ACCOUNT
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType
-import javax.sql.DataSource
-import kotlin.streams.toList
-import kotlin.test.Test
-
-
-class KotlinTest {
- @Test
- fun testDb() {
- val dataSource: DataSource = EmbeddedDatabaseBuilder()
- .setType(EmbeddedDatabaseType.H2)
- .addScript("schema.sql")
- .addScript("data-kt.sql")
- .build()
-
- AuditManager.setAuditEnable(true)
- AuditManager.setMessageCollector(ConsoleMessageCollector())
-
- buildBootstrap {
-// 此方法体 it 是 MybatisFlexBootstrap 实例
-// 配置Mapper
-// 1.通过+(重写自增)的方式
- +AccountMapper::class.java
-// 2.通过原始的方式
-// it.addMapper(AccountMapper::class.java)
-
-// 配置单dataSource
-// 1.通过+(重写自增)的方式
- +dataSource
-// 2.通过原始的方式
-// it.setDataSource(dataSource)
-
-// 配置多dataSource
-// 1.通过of(中缀)的方式
- FlexConsts.NAME of dataSource
-// "dataSource1" of dataSource
-// "dataSource2" of dataSource
-// 2.通过dsl(中缀)的方式
- dataSources {
-// dataSource(FlexConsts.NAME,dataSource)
-// dataSource("dataSource1",dataSource)
-// dataSource("dataSource2",dataSource)
- }
-// 3.通过原始的方式
-// it.addDataSource(FlexConsts.NAME,dataSource)
- }.start()
-
-// 查询表对象对应的所有实体数据
- ACCOUNT.all