style: code format.

This commit is contained in:
Suomm 2023-07-14 16:14:45 +08:00
parent 8b621fbdc9
commit f03ad784c9
269 changed files with 3427 additions and 2448 deletions

View File

@ -24,4 +24,5 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface EnumValue {
}
}

View File

@ -107,7 +107,7 @@ public class Generator {
buildPrimaryKey(table);
dialect.buildTableColumns(schemaName,table, globalConfig, dbMeta, conn);
dialect.buildTableColumns(schemaName, table, globalConfig, dbMeta, conn);
tables.add(table);
}

View File

@ -70,26 +70,26 @@ public interface IDialect {
@Override
protected ResultSet forRemarks(String schema, Table table, DatabaseMetaData dbMeta, Connection conn) throws SQLException {
if (conn instanceof OracleConnection){
if (conn instanceof OracleConnection) {
((OracleConnection) conn).setRemarksReporting(true);
return dbMeta.getColumns(conn.getCatalog(), StringUtil.isNotBlank(schema) ? schema : dbMeta.getUserName(), table.getName(), null);
}else if ("com.zaxxer.hikari.pool.HikariProxyConnection".equals(conn.getClass().getName())){
return forRemarks(schema,table,dbMeta,getOriginalConn(HikariProxyConnection.class,"delegate",conn));
}else if ("com.alibaba.druid.pool.DruidPooledConnection".equals(conn.getClass().getName())){
return forRemarks(schema,table,dbMeta,getOriginalConn(DruidPooledConnection.class,"conn",conn));
} else if ("com.zaxxer.hikari.pool.HikariProxyConnection".equals(conn.getClass().getName())) {
return forRemarks(schema, table, dbMeta, getOriginalConn(HikariProxyConnection.class, "delegate", conn));
} else if ("com.alibaba.druid.pool.DruidPooledConnection".equals(conn.getClass().getName())) {
return forRemarks(schema, table, dbMeta, getOriginalConn(DruidPooledConnection.class, "conn", conn));
}
return null;
}
}
private Connection getOriginalConn(Class<?> clazz,String attr,Connection conn){
Field delegate = ClassUtil.getFirstField(clazz, field -> field.getName().equals(attr));
try {
delegate.setAccessible(true);
return (Connection) delegate.get(conn);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
private Connection getOriginalConn(Class<?> clazz, String attr, Connection conn) {
Field delegate = ClassUtil.getFirstField(clazz, field -> field.getName().equals(attr));
try {
delegate.setAccessible(true);
return (Connection) delegate.get(conn);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
};
/**

View File

@ -30,7 +30,7 @@ public abstract class JdbcDialect implements IDialect {
@Override
public void buildTableColumns(String schemaName, Table table, GlobalConfig globalConfig, DatabaseMetaData dbMeta, Connection conn) throws SQLException {
Map<String, String> columnRemarks = buildColumnRemarks(schemaName,table, dbMeta, conn);
Map<String, String> columnRemarks = buildColumnRemarks(schemaName, table, dbMeta, conn);
String sql = forBuildColumnsSql(table.getSchema(), table.getName());
try (Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery(sql)) {
@ -58,7 +58,7 @@ public abstract class JdbcDialect implements IDialect {
private Map<String, String> buildColumnRemarks(String schemaName, Table table, DatabaseMetaData dbMeta, Connection conn) {
Map<String, String> columnRemarks = new HashMap<>();
try (ResultSet colRs = forRemarks(schemaName,table, dbMeta, conn)) {
try (ResultSet colRs = forRemarks(schemaName, table, dbMeta, conn)) {
while (colRs.next()) {
columnRemarks.put(colRs.getString("COLUMN_NAME"), colRs.getString("REMARKS"));
}
@ -99,7 +99,4 @@ public abstract class JdbcDialect implements IDialect {
}
}

View File

@ -153,8 +153,8 @@ public class Column {
return "";
} else {
return "/**\n" +
" * " + comment + "\n" +
" */";
" * " + comment + "\n" +
" */";
}
}
@ -199,14 +199,14 @@ public class Column {
//@Column 注解
if (columnConfig.getOnInsertValue() != null
|| columnConfig.getOnUpdateValue() != null
|| columnConfig.getLarge() != null
|| columnConfig.getLogicDelete() != null
|| columnConfig.getVersion() != null
|| columnConfig.getJdbcType() != null
|| columnConfig.getTypeHandler() != null
|| columnConfig.getTenantId() != null
|| needGenColumnAnnotation
|| columnConfig.getOnUpdateValue() != null
|| columnConfig.getLarge() != null
|| columnConfig.getLogicDelete() != null
|| columnConfig.getVersion() != null
|| columnConfig.getJdbcType() != null
|| columnConfig.getTypeHandler() != null
|| columnConfig.getTenantId() != null
|| needGenColumnAnnotation
) {
annotations.append("@Column(");
boolean needComma = false;
@ -280,8 +280,8 @@ public class Column {
//lang 包不需要显式导入
if (!propertyType.startsWith("java.lang.")
&& !"byte[]".equals(propertyType)
&& !"Byte[]".equals(propertyType)
&& !"byte[]".equals(propertyType)
&& !"Byte[]".equals(propertyType)
) {
importClasses.add(propertyType);
}
@ -308,14 +308,14 @@ public class Column {
}
if (columnConfig.getOnInsertValue() != null
|| columnConfig.getOnUpdateValue() != null
|| columnConfig.getLarge() != null
|| columnConfig.getLogicDelete() != null
|| columnConfig.getVersion() != null
|| columnConfig.getJdbcType() != null
|| columnConfig.getTypeHandler() != null
|| Boolean.TRUE.equals(columnConfig.getTenantId())
|| needGenColumnAnnotation
|| columnConfig.getOnUpdateValue() != null
|| columnConfig.getLarge() != null
|| columnConfig.getLogicDelete() != null
|| columnConfig.getVersion() != null
|| columnConfig.getJdbcType() != null
|| columnConfig.getTypeHandler() != null
|| Boolean.TRUE.equals(columnConfig.getTenantId())
|| needGenColumnAnnotation
) {
importClasses.add(com.mybatisflex.annotation.Column.class.getName());
}
@ -336,11 +336,11 @@ public class Column {
@Override
public String toString() {
return "Column{" +
"name='" + name + '\'' +
", className='" + propertyType + '\'' +
", remarks='" + comment + '\'' +
", isAutoIncrement=" + isAutoIncrement +
'}';
"name='" + name + '\'' +
", className='" + propertyType + '\'' +
", remarks='" + comment + '\'' +
", isAutoIncrement=" + isAutoIncrement +
'}';
}
}

View File

@ -92,10 +92,10 @@ public class Table {
public String getPrimaryKey() {
// 这里默认表中一定会有字段就不做空判断了
return columns.stream()
.filter(Column::isPrimaryKey)
.findFirst()
.map(Column::getProperty)
.orElse(null);
.filter(Column::isPrimaryKey)
.findFirst()
.map(Column::getProperty)
.orElse(null);
}
public Set<String> getPrimaryKeys() {
@ -271,7 +271,7 @@ public class Table {
Class<?>[] entityInterfaces = globalConfig.getEntityConfig().getImplInterfaces();
if (entityInterfaces != null && entityInterfaces.length > 0) {
return " implements " + StringUtil.join(", ", Arrays.stream(entityInterfaces)
.map(Class::getSimpleName).collect(Collectors.toList()));
.map(Class::getSimpleName).collect(Collectors.toList()));
} else {
return "";
}
@ -305,8 +305,8 @@ public class Table {
String entityJavaFileName = getEntityJavaFileName();
EntityConfig entityConfig = globalConfig.getEntityConfig();
return entityConfig.getClassPrefix()
+ entityJavaFileName
+ entityConfig.getClassSuffix();
+ entityJavaFileName
+ entityConfig.getClassSuffix();
}
/**
@ -316,8 +316,8 @@ public class Table {
String tableDefJavaFileName = getEntityJavaFileName();
TableDefConfig tableDefConfig = globalConfig.getTableDefConfig();
return tableDefConfig.getClassPrefix()
+ tableDefJavaFileName
+ tableDefConfig.getClassSuffix();
+ tableDefJavaFileName
+ tableDefConfig.getClassSuffix();
}
/**
@ -327,8 +327,8 @@ public class Table {
String entityJavaFileName = getEntityJavaFileName();
MapperConfig mapperConfig = globalConfig.getMapperConfig();
return mapperConfig.getClassPrefix()
+ entityJavaFileName
+ mapperConfig.getClassSuffix();
+ entityJavaFileName
+ mapperConfig.getClassSuffix();
}
/**
@ -338,8 +338,8 @@ public class Table {
String entityJavaFileName = getEntityJavaFileName();
ServiceConfig serviceConfig = globalConfig.getServiceConfig();
return serviceConfig.getClassPrefix()
+ entityJavaFileName
+ serviceConfig.getClassSuffix();
+ entityJavaFileName
+ serviceConfig.getClassSuffix();
}
/**
@ -349,8 +349,8 @@ public class Table {
String entityJavaFileName = getEntityJavaFileName();
ServiceImplConfig serviceImplConfig = globalConfig.getServiceImplConfig();
return serviceImplConfig.getClassPrefix()
+ entityJavaFileName
+ serviceImplConfig.getClassSuffix();
+ entityJavaFileName
+ serviceImplConfig.getClassSuffix();
}
/**
@ -360,8 +360,8 @@ public class Table {
String entityJavaFileName = getEntityJavaFileName();
ControllerConfig controllerConfig = globalConfig.getControllerConfig();
return controllerConfig.getClassPrefix()
+ entityJavaFileName
+ controllerConfig.getClassSuffix();
+ entityJavaFileName
+ controllerConfig.getClassSuffix();
}
/**
@ -371,19 +371,19 @@ public class Table {
String tableDefJavaFileName = getEntityJavaFileName();
MapperXmlConfig mapperXmlConfig = globalConfig.getMapperXmlConfig();
return mapperXmlConfig.getFilePrefix()
+ tableDefJavaFileName
+ mapperXmlConfig.getFileSuffix();
+ tableDefJavaFileName
+ mapperXmlConfig.getFileSuffix();
}
@Override
public String toString() {
return "Table{" +
"schema'" + schema + '\'' +
"name='" + name + '\'' +
", remarks='" + comment + '\'' +
", primaryKeys='" + primaryKeys + '\'' +
", columns=" + columns +
'}';
"schema'" + schema + '\'' +
"name='" + name + '\'' +
", remarks='" + comment + '\'' +
", primaryKeys='" + primaryKeys + '\'' +
", columns=" + columns +
'}';
}
}

View File

@ -56,7 +56,7 @@ public class ControllerGenerator implements IGenerator {
String controllerPackagePath = packageConfig.getControllerPackage().replace(".", "/");
File controllerJavaFile = new File(packageConfig.getSourceDir(), controllerPackagePath + "/" +
table.buildControllerClassName() + ".java");
table.buildControllerClassName() + ".java");
if (controllerJavaFile.exists() && !controllerConfig.isOverwriteEnable()) {

View File

@ -56,7 +56,7 @@ public class EntityGenerator implements IGenerator {
String entityPackagePath = packageConfig.getEntityPackage().replace(".", "/");
File entityJavaFile = new File(packageConfig.getSourceDir(), entityPackagePath + "/" +
table.buildEntityClassName() + ".java");
table.buildEntityClassName() + ".java");
if (entityJavaFile.exists() && !entityConfig.isOverwriteEnable()) {

View File

@ -53,10 +53,10 @@ public class MapperGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig();
MapperConfig mapperConfig = globalConfig.getMapperConfig();
String mapperPackagePath = packageConfig.getMapperPackage().replace(".", "/");
File mapperJavaFile = new File(packageConfig.getSourceDir(), mapperPackagePath + "/" +
table.buildMapperClassName() + ".java");
table.buildMapperClassName() + ".java");
if (mapperJavaFile.exists() && !mapperConfig.isOverwriteEnable()) {

View File

@ -55,7 +55,7 @@ public class MapperXmlGenerator implements IGenerator {
MapperXmlConfig mapperXmlConfig = globalConfig.getMapperXmlConfig();
File mapperXmlFile = new File(packageConfig.getMapperXmlPath() + "/" +
table.buildMapperXmlFileName() + ".xml");
table.buildMapperXmlFileName() + ".xml");
if (mapperXmlFile.exists() && !mapperXmlConfig.isOverwriteEnable()) {

View File

@ -53,10 +53,10 @@ public class ServiceGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig();
ServiceConfig serviceConfig = globalConfig.getServiceConfig();
String servicePackagePath = packageConfig.getServicePackage().replace(".", "/");
File serviceJavaFile = new File(packageConfig.getSourceDir(), servicePackagePath + "/" +
table.buildServiceClassName() + ".java");
table.buildServiceClassName() + ".java");
if (serviceJavaFile.exists() && !serviceConfig.isOverwriteEnable()) {

View File

@ -53,10 +53,10 @@ public class ServiceImplGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig();
ServiceImplConfig serviceImplConfig = globalConfig.getServiceImplConfig();
String serviceImplPackagePath = packageConfig.getServiceImplPackage().replace(".", "/");
File serviceImplJavaFile = new File(packageConfig.getSourceDir(), serviceImplPackagePath + "/" +
table.buildServiceImplClassName() + ".java");
table.buildServiceImplClassName() + ".java");
if (serviceImplJavaFile.exists() && !serviceImplConfig.isOverwriteEnable()) {

View File

@ -47,7 +47,7 @@ public class TableDefGenerator implements IGenerator {
@Override
public void generate(Table table, GlobalConfig globalConfig) {
if (!globalConfig.isTableDefGenerateEnable()){
if (!globalConfig.isTableDefGenerateEnable()) {
return;
}
@ -56,7 +56,7 @@ public class TableDefGenerator implements IGenerator {
String tableDefPackagePath = packageConfig.getTableDefPackage().replace(".", "/");
File tableDefJavaFile = new File(packageConfig.getSourceDir(), tableDefPackagePath + "/" +
table.buildTableDefClassName() + ".java");
table.buildTableDefClassName() + ".java");
if (tableDefJavaFile.exists() && !tableDefConfig.isOverwriteEnable()) {

View File

@ -1,8 +1,25 @@
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.codegen.test;
import java.util.Date;
public class BaseEntity {
private Date createTime;
public Date getCreateTime() {
@ -12,4 +29,5 @@ public class BaseEntity {
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -148,7 +148,7 @@ public class GeneratorTest {
generator.generate();
}
// @Test
// @Test
public void testCodeGen3() {
//配置数据源
HikariDataSource dataSource = new HikariDataSource();

View File

@ -1,6 +1,23 @@
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.codegen.test;
import com.mybatisflex.core.BaseMapper;
public interface MyBaseMapper<T> extends BaseMapper<T> {
public interface MyBaseMapper<T> extends BaseMapper<T> {
}

View File

@ -1,10 +1,28 @@
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.codegen.test;
import com.mybatisflex.annotation.UpdateListener;
public class MyUpdateListener implements UpdateListener {
@Override
public void onUpdate(Object entity) {
}
}

View File

@ -17,11 +17,9 @@
package com.mybatisflex.codegen.test;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.mybatisflex.codegen.dialect.IDialect;
import org.junit.Test;
import javax.sql.DataSource;
import java.sql.Connection;
@ -29,7 +27,7 @@ import java.sql.Statement;
public class SqliteGeneratorTest {
// @Test
// @Test
public void testGenerator3() {
//配置数据源
@ -50,15 +48,15 @@ public class SqliteGeneratorTest {
//配置生成文件目录与根包
globalConfig.getPackageConfig()
.setSourceDir(System.getProperty("user.dir") + "/src/test/java")
.setBasePackage("com.test");
.setSourceDir(System.getProperty("user.dir") + "/src/test/java")
.setBasePackage("com.test");
//设置只生成哪些表
globalConfig.getStrategyConfig()
.setGenerateTable("person");
.setGenerateTable("person");
globalConfig.enableEntity()
.setWithLombok(true);
.setWithLombok(true);
//设置生成 mapper
globalConfig.enableMapper();
@ -85,4 +83,5 @@ public class SqliteGeneratorTest {
e.printStackTrace();
}
}
}

View File

@ -20,7 +20,8 @@ package com.mybatisflex.core;
*/
public class FlexConsts {
private FlexConsts() {}
private FlexConsts() {
}
public static final String NAME = "MyBatis-Flex";
public static final String VERSION = "1.4.9";
@ -57,4 +58,5 @@ public class FlexConsts {
* entity 使用逻辑删除时1 entity 的删除状态
*/
public static final int LOGIC_DELETE_DELETED = 1;
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core;
@ -23,7 +23,10 @@ import com.mybatisflex.core.dialect.DbType;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
@ -317,6 +320,7 @@ public class FlexGlobalConfig {
* 对应的是 注解 {@link com.mybatisflex.annotation.Id} 的配置
*/
public static class KeyConfig {
private KeyType keyType;
private String value;
private boolean before = true;
@ -344,6 +348,7 @@ public class FlexGlobalConfig {
public void setBefore(boolean before) {
this.before = before;
}
}
@ -390,7 +395,7 @@ public class FlexGlobalConfig {
defaultConfig.setConfiguration(config.configuration);
if (defaultConfig.getKeyConfig() == null
&& config.keyConfig != null) {
&& config.keyConfig != null) {
defaultConfig.setKeyConfig(config.keyConfig);
}
@ -399,4 +404,5 @@ public class FlexGlobalConfig {
globalConfigs.put(id, config);
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core;
@ -156,14 +156,14 @@ public class MybatisFlexBootstrap {
*/
public <T> T getMapper(Class<T> mapperClass) {
Object mapperObject = MapUtil.computeIfAbsent(mapperObjects, mapperClass, clazz ->
Proxy.newProxyInstance(mapperClass.getClassLoader()
, new Class[]{mapperClass}
, (proxy, method, args) -> {
try (SqlSession sqlSession = openSession()) {
T mapper1 = sqlSession.getMapper(mapperClass);
return method.invoke(mapper1, args);
}
}));
Proxy.newProxyInstance(mapperClass.getClassLoader()
, new Class[]{mapperClass}
, (proxy, method, args) -> {
try (SqlSession sqlSession = openSession()) {
T mapper1 = sqlSession.getMapper(mapperClass);
return method.invoke(mapper1, args);
}
}));
return (T) mapperObject;
}
@ -241,4 +241,5 @@ public class MybatisFlexBootstrap {
this.logImpl = logImpl;
return this;
}
}

View File

@ -151,7 +151,9 @@ public class AuditManager {
@FunctionalInterface
public interface AuditRunnable<T> {
T execute() throws SQLException;
}
}

View File

@ -25,7 +25,10 @@ import java.lang.reflect.Proxy;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* SQL 审计详细消息
@ -207,15 +210,15 @@ public class AuditMessage implements Serializable {
private PreparedStatement createPreparedStatement(Statement statement) {
return (PreparedStatement) Proxy.newProxyInstance(
AuditMessage.class.getClassLoader(),
new Class[]{PreparedStatement.class}, (proxy, method, args) -> {
if (args != null && (args.length == 2 || args.length == 3)) {
doAddParam(statement, args[1]);
} else if ("getConnection".equals(method.getName())) {
return statement.getConnection();
}
return null;
});
AuditMessage.class.getClassLoader(),
new Class[]{PreparedStatement.class}, (proxy, method, args) -> {
if (args != null && (args.length == 2 || args.length == 3)) {
doAddParam(statement, args[1]);
} else if ("getConnection".equals(method.getName())) {
return statement.getConnection();
}
return null;
});
}
public int getQueryCount() {
@ -260,20 +263,20 @@ public class AuditMessage implements Serializable {
@Override
public String toString() {
return "AuditMessage{" +
"platform='" + platform + '\'' +
", module='" + module + '\'' +
", url='" + url + '\'' +
", bizId='" + bizId + '\'' +
", user='" + user + '\'' +
", userIp='" + userIp + '\'' +
", hostIp='" + hostIp + '\'' +
", query='" + query + '\'' +
", queryParams=" + queryParams +
", queryCount=" + queryCount +
", queryTime=" + queryTime +
", elapsedTime=" + elapsedTime +
", metas=" + metas +
'}';
"platform='" + platform + '\'' +
", module='" + module + '\'' +
", url='" + url + '\'' +
", bizId='" + bizId + '\'' +
", user='" + user + '\'' +
", userIp='" + userIp + '\'' +
", hostIp='" + hostIp + '\'' +
", query='" + query + '\'' +
", queryParams=" + queryParams +
", queryCount=" + queryCount +
", queryTime=" + queryTime +
", elapsedTime=" + elapsedTime +
", metas=" + metas +
'}';
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.audit;
@ -20,6 +20,6 @@ package com.mybatisflex.core.audit;
*/
public interface Clock {
long getTick();
long getTick();
}

View File

@ -39,6 +39,9 @@ public class ConsoleMessageCollector implements MessageCollector {
}
public interface SqlDebugPrinter {
void print(String sql, Long tookTimeMillis);
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.audit;
@ -19,5 +19,7 @@ package com.mybatisflex.core.audit;
* 审计消息收集器
*/
public interface MessageCollector {
void collect(AuditMessage message);
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.audit;
@ -21,6 +21,6 @@ package com.mybatisflex.core.audit;
*/
public interface MessageFactory {
AuditMessage create();
AuditMessage create();
}

View File

@ -81,4 +81,5 @@ public class ScheduledMessageCollector implements MessageCollector, Runnable {
run(); //clear the messages
scheduler.shutdown();
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.audit.http;
@ -41,7 +41,9 @@ public class HttpMessageReporter implements MessageReporter {
}
public interface JSONFormatter {
String toJSONString(Object object);
}
}

View File

@ -38,7 +38,8 @@ import java.util.Map.Entry;
*/
public class HttpUtil {
private HttpUtil() {}
private HttpUtil() {
}
private static final String POST = "POST";
@ -74,16 +75,19 @@ public class HttpUtil {
* https 域名校验
*/
private static class TrustAnyHostnameVerifier implements HostnameVerifier {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
/**
* https 证书管理
*/
private static class TrustAnyTrustManager implements X509TrustManager {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
@ -96,6 +100,7 @@ public class HttpUtil {
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.datasource;
@ -25,60 +25,58 @@ import java.util.logging.Logger;
public abstract class AbstractDataSource implements DataSource {
/**
* Returns 0, indicating the default system timeout is to be used.
*/
@Override
public int getLoginTimeout() throws SQLException {
return 0;
}
/**
* Returns 0, indicating the default system timeout is to be used.
*/
@Override
public int getLoginTimeout() throws SQLException {
return 0;
}
/**
* Setting a login timeout is not supported.
*/
@Override
public void setLoginTimeout(int timeout) throws SQLException {
throw new UnsupportedOperationException("setLoginTimeout");
}
/**
* Setting a login timeout is not supported.
*/
@Override
public void setLoginTimeout(int timeout) throws SQLException {
throw new UnsupportedOperationException("setLoginTimeout");
}
/**
* LogWriter methods are not supported.
*/
@Override
public PrintWriter getLogWriter() {
throw new UnsupportedOperationException("getLogWriter");
}
/**
* LogWriter methods are not supported.
*/
@Override
public PrintWriter getLogWriter() {
throw new UnsupportedOperationException("getLogWriter");
}
/**
* LogWriter methods are not supported.
*/
@Override
public void setLogWriter(PrintWriter pw) throws SQLException {
throw new UnsupportedOperationException("setLogWriter");
}
/**
* LogWriter methods are not supported.
*/
@Override
public void setLogWriter(PrintWriter pw) throws SQLException {
throw new UnsupportedOperationException("setLogWriter");
}
@Override
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface.isInstance(this)) {
return (T) this;
}
throw new SQLException("DataSource of type [" + getClass().getName() +
"] cannot be unwrapped as [" + iface.getName() + "]");
}
@Override
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface.isInstance(this)) {
return (T) this;
}
throw new SQLException("DataSource of type [" + getClass().getName() +
"] cannot be unwrapped as [" + iface.getName() + "]");
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return iface.isInstance(this);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return iface.isInstance(this);
}
@Override
public Logger getParentLogger() {
return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
}
@Override
public Logger getParentLogger() {
return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.datasource;
@ -113,10 +113,10 @@ public class DataSourceBuilder {
private String detectDataSourceClass() {
String[] detectClassNames = new String[]{
"com.alibaba.druid.pool.DruidDataSource",
"com.zaxxer.hikari.HikariDataSource",
"cn.beecp.BeeDataSource",
"org.apache.commons.dbcp2.BasicDataSource",
"com.alibaba.druid.pool.DruidDataSource",
"com.zaxxer.hikari.HikariDataSource",
"cn.beecp.BeeDataSource",
"org.apache.commons.dbcp2.BasicDataSource",
};
for (String detectClassName : detectClassNames) {
@ -138,4 +138,5 @@ public class DataSourceBuilder {
return null;
}
}
}

View File

@ -19,7 +19,8 @@ import java.util.function.Supplier;
public class DataSourceKey {
private DataSourceKey() {}
private DataSourceKey() {
}
private static final ThreadLocal<String> keyThreadLocal = new ThreadLocal<>();

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.datasource;
@ -139,7 +139,7 @@ public class FlexDataSource extends AbstractDataSource {
} catch (SQLException e) {
if (log.isDebugEnabled()) {
log.debug("Error resetting autocommit to true "
+ "before closing the connection. Cause: " + e);
+ "before closing the connection. Cause: " + e);
}
}
}
@ -147,8 +147,8 @@ public class FlexDataSource extends AbstractDataSource {
public Connection proxy(Connection connection, String xid) {
return (Connection) Proxy.newProxyInstance(FlexDataSource.class.getClassLoader()
, new Class[]{Connection.class}
, new ConnectionHandler(connection, xid));
, new Class[]{Connection.class}
, new ConnectionHandler(connection, xid));
}
/**
@ -188,6 +188,7 @@ public class FlexDataSource extends AbstractDataSource {
}
private static class ConnectionHandler implements InvocationHandler {
private static final String[] proxyMethods = new String[]{"commit", "rollback", "close", "setAutoCommit"};
private final Connection original;
private final String xid;
@ -203,7 +204,7 @@ public class FlexDataSource extends AbstractDataSource {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (ArrayUtil.contains(proxyMethods, method.getName())
&& isTransactional()) {
&& isTransactional()) {
//do nothing
return null;
}
@ -219,6 +220,7 @@ public class FlexDataSource extends AbstractDataSource {
private boolean isTransactional() {
return Objects.equals(xid, TransactionContext.getXID());
}
}

View File

@ -160,7 +160,7 @@ public class DbTypeUtil {
return DbType.TDENGINE;
} else if (jdbcUrl.contains(":informix")) {
return DbType.INFORMIX;
}else if (jdbcUrl.contains(":sinodb")) {
} else if (jdbcUrl.contains(":sinodb")) {
return DbType.SINODB;
} else if (jdbcUrl.contains(":uxdb:")) {
return DbType.UXDB;
@ -180,4 +180,5 @@ public class DbTypeUtil {
}
return Pattern.compile(regex).matcher(jdbcUrl).find();
}
}

View File

@ -30,7 +30,8 @@ import java.util.Map;
*/
public class DialectFactory {
private DialectFactory() {}
private DialectFactory() {
}
/**
* 数据库类型和方言的映射关系可以通过其读取指定的方言亦可能通过其扩展其他方言
@ -134,8 +135,8 @@ public class DialectFactory {
return new CommonsDialectImpl(KeywordWrap.DOUBLE_QUOTATION, LimitOffsetProcessor.DERBY);
case SQLSERVER:
return new CommonsDialectImpl(KeywordWrap.SQUARE_BRACKETS, LimitOffsetProcessor.SQLSERVER);
case SQLSERVER_2005:
return new CommonsDialectImpl(KeywordWrap.SQUARE_BRACKETS, LimitOffsetProcessor.SQLSERVER_2005);
case SQLSERVER_2005:
return new CommonsDialectImpl(KeywordWrap.SQUARE_BRACKETS, LimitOffsetProcessor.SQLSERVER_2005);
case INFORMIX:
return new CommonsDialectImpl(KeywordWrap.DOUBLE_QUOTATION, LimitOffsetProcessor.INFORMIX);
case SINODB:
@ -146,4 +147,5 @@ public class DialectFactory {
return new CommonsDialectImpl();
}
}
}

View File

@ -15,7 +15,10 @@
*/
package com.mybatisflex.core.dialect;
import com.mybatisflex.core.query.*;
import com.mybatisflex.core.query.CPI;
import com.mybatisflex.core.query.QueryOrderBy;
import com.mybatisflex.core.query.QueryTable;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.util.CollectionUtil;
import java.util.List;

View File

@ -36,50 +36,50 @@ public class OracleDialect extends CommonsDialectImpl {
//https://docs.oracle.com/cd/A97630_01/appdev.920/a42525/apb.htm
public static final Set<String> keywords = CollectionUtil.newHashSet(
"ACCESS", "ELSE", "MODIFY", "START", "ADD", "EXCLUSIVE", "NOAUDIT", "SELECT",
"ALL", "EXISTS", "NOCOMPRESS", "SESSION", "ALTER", "FILE", "NOT", "SET", "AND", "FLOAT",
"NOTFOUND", "SHARE", "ANY", "FOR", "NOWAIT", "SIZE", "ARRAYLEN", "FROM", "NULL", "SMALLINT",
"AS", "GRANT", "NUMBER", "SQLBUF", "ASC", "GROUP", "OF", "SUCCESSFUL", "AUDIT", "HAVING",
"OFFLINE", "SYNONYM", "BETWEEN", "IDENTIFIED", "ON", "SYSDATE", "BY", "IMMEDIATE", "ONLINE",
"TABLE", "CHAR", "IN", "OPTION", "THEN", "CHECK", "INCREMENT", "OR", "TO", "CLUSTER", "INDEX",
"ORDER", "TRIGGER", "COLUMN", "INITIAL", "PCTFREE", "UID", "COMMENT", "INSERT", "PRIOR",
"UNION", "COMPRESS", "INTEGER", "PRIVILEGES", "UNIQUE", "CONNECT", "INTERSECT", "PUBLIC",
"UPDATE", "CREATE", "INTO", "RAW", "USER", "CURRENT", "IS", "RENAME", "VALIDATE", "DATE", "LEVEL",
"RESOURCE", "VALUES", "DECIMAL", "LIKE", "REVOKE", "VARCHAR", "DEFAULT", "LOCK", "ROW", "VARCHAR2",
"DELETE", "LONG", "ROWID", "VIEW", "DESC", "MAXEXTENTS", "ROWLABEL", "WHENEVER", "DISTINCT", "MINUS",
"ROWNUM", "WHERE", "DROP", "MODE", "ROWS", "WITH", "ADMIN", "CURSOR", "FOUND", "MOUNT", "AFTER", "CYCLE",
"FUNCTION", "NEXT", "ALLOCATE", "DATABASE", "GO", "NEW", "ANALYZE", "DATAFILE", "GOTO", "NOARCHIVELOG",
"ARCHIVE", "DBA", "GROUPS", "NOCACHE", "ARCHIVELOG", "DEC", "INCLUDING", "NOCYCLE", "AUTHORIZATION",
"DECLARE", "INDICATOR", "NOMAXVALUE", "AVG", "DISABLE", "INITRANS", "NOMINVALUE", "BACKUP", "DISMOUNT",
"INSTANCE", "NONE", "BEGIN", "DOUBLE", "INT", "NOORDER", "BECOME", "DUMP", "KEY", "NORESETLOGS", "BEFORE",
"EACH", "LANGUAGE", "NORMAL", "BLOCK", "ENABLE", "LAYER", "NOSORT", "BODY", "END", "LINK", "NUMERIC", "CACHE",
"ESCAPE", "LISTS", "OFF", "CANCEL", "EVENTS", "LOGFILE", "OLD", "CASCADE", "EXCEPT", "MANAGE", "ONLY", "CHANGE",
"EXCEPTIONS", "MANUAL", "OPEN", "CHARACTER", "EXEC", "MAX", "OPTIMAL", "CHECKPOINT", "EXPLAIN", "MAXDATAFILES",
"OWN", "CLOSE", "EXECUTE", "MAXINSTANCES", "PACKAGE", "COBOL", "EXTENT", "MAXLOGFILES", "PARALLEL", "COMMIT",
"EXTERNALLY", "MAXLOGHISTORY", "PCTINCREASE", "COMPILE", "FETCH", "MAXLOGMEMBERS", "PCTUSED", "CONSTRAINT",
"FLUSH", "MAXTRANS", "PLAN", "CONSTRAINTS", "FREELIST", "MAXVALUE", "PLI", "CONTENTS", "FREELISTS", "MIN",
"PRECISION", "CONTINUE", "FORCE", "MINEXTENTS", "PRIMARY", "CONTROLFILE", "FOREIGN", "MINVALUE", "PRIVATE",
"COUNT", "FORTRAN", "MODULE", "PROCEDURE", "PROFILE", "SAVEPOINT", "SQLSTATE", "TRACING", "QUOTA", "SCHEMA",
"STATEMENT_ID", "TRANSACTION", "READ", "SCN", "STATISTICS", "TRIGGERS", "REAL", "SECTION", "STOP", "TRUNCATE",
"RECOVER", "SEGMENT", "STORAGE", "UNDER", "REFERENCES", "SEQUENCE", "SUM", "UNLIMITED", "REFERENCING", "SHARED",
"SWITCH", "UNTIL", "RESETLOGS", "SNAPSHOT", "SYSTEM", "USE", "RESTRICTED", "SOME", "TABLES", "USING", "REUSE",
"SORT", "TABLESPACE", "WHEN", "ROLE", "SQL", "TEMPORARY", "WRITE", "ROLES", "SQLCODE", "THREAD", "WORK", "ROLLBACK",
"SQLERROR", "TIME", "ABORT", "BETWEEN", "CRASH", "DIGITS", "ACCEPT", "BINARY_INTEGER", "CREATE", "DISPOSE", "ACCESS",
"BODY", "CURRENT", "DISTINCT", "ADD", "BOOLEAN", "CURRVAL", "DO", "ALL", "BY", "CURSOR", "DROP", "ALTER", "CASE", "DATABASE",
"ELSE", "AND", "CHAR", "DATA_BASE", "ELSIF", "ANY", "CHAR_BASE", "DATE", "END", "ARRAY", "CHECK", "DBA", "ENTRY", "ARRAYLEN",
"CLOSE", "DEBUGOFF", "EXCEPTION", "AS", "CLUSTER", "DEBUGON", "EXCEPTION_INIT", "ASC", "CLUSTERS", "DECLARE", "EXISTS",
"ASSERT", "COLAUTH", "DECIMAL", "EXIT", "ASSIGN", "COLUMNS", "DEFAULT", "FALSE", "AT", "COMMIT", "DEFINITION", "FETCH",
"AUTHORIZATION", "COMPRESS", "DELAY", "FLOAT", "AVG", "CONNECT", "DELETE", "FOR", "BASE_TABLE", "CONSTANT", "DELTA", "FORM",
"BEGIN", "COUNT", "DESC", "FROM", "FUNCTION", "NEW", "RELEASE", "SUM", "GENERIC", "NEXTVAL", "REMR", "TABAUTH",
"GOTO", "NOCOMPRESS", "RENAME", "TABLE", "GRANT", "NOT", "RESOURCE", "TABLES", "GROUP", "NULL", "RETURN", "TASK", "HAVING",
"NUMBER", "REVERSE", "TERMINATE", "IDENTIFIED", "NUMBER_BASE", "REVOKE", "THEN", "IF", "OF", "ROLLBACK", "TO", "IN", "ON",
"ROWID", "TRUE", "INDEX", "OPEN", "ROWLABEL", "TYPE", "INDEXES", "OPTION", "ROWNUM", "UNION", "INDICATOR", "OR", "ROWTYPE",
"UNIQUE", "INSERT", "ORDER", "RUN", "UPDATE", "INTEGER", "OTHERS", "SAVEPOINT", "USE", "INTERSECT", "OUT", "SCHEMA", "VALUES",
"INTO", "PACKAGE", "SELECT", "VARCHAR", "IS", "PARTITION", "SEPARATE", "VARCHAR2", "LEVEL", "PCTFREE", "SET", "VARIANCE",
"LIKE", "POSITIVE", "SIZE", "VIEW", "LIMITED", "PRAGMA", "SMALLINT", "VIEWS", "LOOP", "PRIOR", "SPACE", "WHEN", "MAX", "PRIVATE",
"SQL", "WHERE", "MIN", "PROCEDURE", "SQLCODE", "WHILE", "MINUS", "PUBLIC", "SQLERRM", "WITH", "MLSLABEL", "RAISE", "START",
"WORK", "MOD", "RANGE", "STATEMENT", "XOR", "MODE", "REAL", "STDDEV", "NATURAL", "RECORD", "SUBTYPE", "GEN", "KP", "L",
"NA", "NC", "ND", "NL", "NM", "NR", "NS", "NT", "NZ", "TTC", "UPI", "O", "S", "XA"
"ACCESS", "ELSE", "MODIFY", "START", "ADD", "EXCLUSIVE", "NOAUDIT", "SELECT",
"ALL", "EXISTS", "NOCOMPRESS", "SESSION", "ALTER", "FILE", "NOT", "SET", "AND", "FLOAT",
"NOTFOUND", "SHARE", "ANY", "FOR", "NOWAIT", "SIZE", "ARRAYLEN", "FROM", "NULL", "SMALLINT",
"AS", "GRANT", "NUMBER", "SQLBUF", "ASC", "GROUP", "OF", "SUCCESSFUL", "AUDIT", "HAVING",
"OFFLINE", "SYNONYM", "BETWEEN", "IDENTIFIED", "ON", "SYSDATE", "BY", "IMMEDIATE", "ONLINE",
"TABLE", "CHAR", "IN", "OPTION", "THEN", "CHECK", "INCREMENT", "OR", "TO", "CLUSTER", "INDEX",
"ORDER", "TRIGGER", "COLUMN", "INITIAL", "PCTFREE", "UID", "COMMENT", "INSERT", "PRIOR",
"UNION", "COMPRESS", "INTEGER", "PRIVILEGES", "UNIQUE", "CONNECT", "INTERSECT", "PUBLIC",
"UPDATE", "CREATE", "INTO", "RAW", "USER", "CURRENT", "IS", "RENAME", "VALIDATE", "DATE", "LEVEL",
"RESOURCE", "VALUES", "DECIMAL", "LIKE", "REVOKE", "VARCHAR", "DEFAULT", "LOCK", "ROW", "VARCHAR2",
"DELETE", "LONG", "ROWID", "VIEW", "DESC", "MAXEXTENTS", "ROWLABEL", "WHENEVER", "DISTINCT", "MINUS",
"ROWNUM", "WHERE", "DROP", "MODE", "ROWS", "WITH", "ADMIN", "CURSOR", "FOUND", "MOUNT", "AFTER", "CYCLE",
"FUNCTION", "NEXT", "ALLOCATE", "DATABASE", "GO", "NEW", "ANALYZE", "DATAFILE", "GOTO", "NOARCHIVELOG",
"ARCHIVE", "DBA", "GROUPS", "NOCACHE", "ARCHIVELOG", "DEC", "INCLUDING", "NOCYCLE", "AUTHORIZATION",
"DECLARE", "INDICATOR", "NOMAXVALUE", "AVG", "DISABLE", "INITRANS", "NOMINVALUE", "BACKUP", "DISMOUNT",
"INSTANCE", "NONE", "BEGIN", "DOUBLE", "INT", "NOORDER", "BECOME", "DUMP", "KEY", "NORESETLOGS", "BEFORE",
"EACH", "LANGUAGE", "NORMAL", "BLOCK", "ENABLE", "LAYER", "NOSORT", "BODY", "END", "LINK", "NUMERIC", "CACHE",
"ESCAPE", "LISTS", "OFF", "CANCEL", "EVENTS", "LOGFILE", "OLD", "CASCADE", "EXCEPT", "MANAGE", "ONLY", "CHANGE",
"EXCEPTIONS", "MANUAL", "OPEN", "CHARACTER", "EXEC", "MAX", "OPTIMAL", "CHECKPOINT", "EXPLAIN", "MAXDATAFILES",
"OWN", "CLOSE", "EXECUTE", "MAXINSTANCES", "PACKAGE", "COBOL", "EXTENT", "MAXLOGFILES", "PARALLEL", "COMMIT",
"EXTERNALLY", "MAXLOGHISTORY", "PCTINCREASE", "COMPILE", "FETCH", "MAXLOGMEMBERS", "PCTUSED", "CONSTRAINT",
"FLUSH", "MAXTRANS", "PLAN", "CONSTRAINTS", "FREELIST", "MAXVALUE", "PLI", "CONTENTS", "FREELISTS", "MIN",
"PRECISION", "CONTINUE", "FORCE", "MINEXTENTS", "PRIMARY", "CONTROLFILE", "FOREIGN", "MINVALUE", "PRIVATE",
"COUNT", "FORTRAN", "MODULE", "PROCEDURE", "PROFILE", "SAVEPOINT", "SQLSTATE", "TRACING", "QUOTA", "SCHEMA",
"STATEMENT_ID", "TRANSACTION", "READ", "SCN", "STATISTICS", "TRIGGERS", "REAL", "SECTION", "STOP", "TRUNCATE",
"RECOVER", "SEGMENT", "STORAGE", "UNDER", "REFERENCES", "SEQUENCE", "SUM", "UNLIMITED", "REFERENCING", "SHARED",
"SWITCH", "UNTIL", "RESETLOGS", "SNAPSHOT", "SYSTEM", "USE", "RESTRICTED", "SOME", "TABLES", "USING", "REUSE",
"SORT", "TABLESPACE", "WHEN", "ROLE", "SQL", "TEMPORARY", "WRITE", "ROLES", "SQLCODE", "THREAD", "WORK", "ROLLBACK",
"SQLERROR", "TIME", "ABORT", "BETWEEN", "CRASH", "DIGITS", "ACCEPT", "BINARY_INTEGER", "CREATE", "DISPOSE", "ACCESS",
"BODY", "CURRENT", "DISTINCT", "ADD", "BOOLEAN", "CURRVAL", "DO", "ALL", "BY", "CURSOR", "DROP", "ALTER", "CASE", "DATABASE",
"ELSE", "AND", "CHAR", "DATA_BASE", "ELSIF", "ANY", "CHAR_BASE", "DATE", "END", "ARRAY", "CHECK", "DBA", "ENTRY", "ARRAYLEN",
"CLOSE", "DEBUGOFF", "EXCEPTION", "AS", "CLUSTER", "DEBUGON", "EXCEPTION_INIT", "ASC", "CLUSTERS", "DECLARE", "EXISTS",
"ASSERT", "COLAUTH", "DECIMAL", "EXIT", "ASSIGN", "COLUMNS", "DEFAULT", "FALSE", "AT", "COMMIT", "DEFINITION", "FETCH",
"AUTHORIZATION", "COMPRESS", "DELAY", "FLOAT", "AVG", "CONNECT", "DELETE", "FOR", "BASE_TABLE", "CONSTANT", "DELTA", "FORM",
"BEGIN", "COUNT", "DESC", "FROM", "FUNCTION", "NEW", "RELEASE", "SUM", "GENERIC", "NEXTVAL", "REMR", "TABAUTH",
"GOTO", "NOCOMPRESS", "RENAME", "TABLE", "GRANT", "NOT", "RESOURCE", "TABLES", "GROUP", "NULL", "RETURN", "TASK", "HAVING",
"NUMBER", "REVERSE", "TERMINATE", "IDENTIFIED", "NUMBER_BASE", "REVOKE", "THEN", "IF", "OF", "ROLLBACK", "TO", "IN", "ON",
"ROWID", "TRUE", "INDEX", "OPEN", "ROWLABEL", "TYPE", "INDEXES", "OPTION", "ROWNUM", "UNION", "INDICATOR", "OR", "ROWTYPE",
"UNIQUE", "INSERT", "ORDER", "RUN", "UPDATE", "INTEGER", "OTHERS", "SAVEPOINT", "USE", "INTERSECT", "OUT", "SCHEMA", "VALUES",
"INTO", "PACKAGE", "SELECT", "VARCHAR", "IS", "PARTITION", "SEPARATE", "VARCHAR2", "LEVEL", "PCTFREE", "SET", "VARIANCE",
"LIKE", "POSITIVE", "SIZE", "VIEW", "LIMITED", "PRAGMA", "SMALLINT", "VIEWS", "LOOP", "PRIOR", "SPACE", "WHEN", "MAX", "PRIVATE",
"SQL", "WHERE", "MIN", "PROCEDURE", "SQLCODE", "WHILE", "MINUS", "PUBLIC", "SQLERRM", "WITH", "MLSLABEL", "RAISE", "START",
"WORK", "MOD", "RANGE", "STATEMENT", "XOR", "MODE", "REAL", "STDDEV", "NATURAL", "RECORD", "SUBTYPE", "GEN", "KP", "L",
"NA", "NC", "ND", "NL", "NM", "NR", "NS", "NT", "NZ", "TTC", "UPI", "O", "S", "XA"
);
@ -166,8 +166,8 @@ public class OracleDialect extends CommonsDialectImpl {
sql.append(INSERT_ALL);
String tableNameWrap = StringUtil.isNotBlank(schema)
? wrap(getRealSchema(schema)) + REFERENCE + wrap(getRealTable(tableName))
: wrap(getRealTable(tableName));
? wrap(getRealSchema(schema)) + REFERENCE + wrap(getRealTable(tableName))
: wrap(getRealTable(tableName));
String questionStrings = SqlUtil.buildSqlParamPlaceholder(attrs.size());
for (int i = 0; i < rows.size(); i++) {
@ -178,4 +178,5 @@ public class OracleDialect extends CommonsDialectImpl {
return sql.append(INSERT_ALL_END).toString();
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.exception;
@ -97,4 +97,5 @@ public final class FlexExceptions {
}
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.exception;
@ -31,5 +31,5 @@ public class MybatisFlexException extends RuntimeException {
super(cause);
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.field;
@ -39,4 +39,5 @@ public class FieldQuery implements Serializable {
public void setQueryWrapper(QueryWrapper queryWrapper) {
this.queryWrapper = queryWrapper;
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.field;
@ -29,16 +29,16 @@ public class FieldQueryBuilder<T> implements Serializable {
this.entity = entity;
}
public FieldQueryBuilder<T> field(String field){
public FieldQueryBuilder<T> field(String field) {
fieldQuery.setField(field);
return this;
}
public FieldQueryBuilder<T> field(LambdaGetter<T> fn){
public FieldQueryBuilder<T> field(LambdaGetter<T> fn) {
return field(LambdaUtil.getFieldName(fn));
}
public FieldQueryBuilder<T> queryWrapper(QueryBuilder<T> fun){
public FieldQueryBuilder<T> queryWrapper(QueryBuilder<T> fun) {
fieldQuery.setQueryWrapper(fun.build(entity));
return this;
}
@ -46,4 +46,5 @@ public class FieldQueryBuilder<T> implements Serializable {
public FieldQuery build() {
return fieldQuery;
}
}

View File

@ -1,22 +1,24 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.field;
import com.mybatisflex.core.query.QueryWrapper;
public interface QueryBuilder<T> {
QueryWrapper build(T entity);
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.handler;
@ -52,4 +52,5 @@ public abstract class BaseJsonTypeHandler<T> extends BaseTypeHandler<T> {
protected abstract T parseJson(String json);
protected abstract String toJson(T object);
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.handler;
@ -60,4 +60,5 @@ public class CompositeEnumTypeHandler<E extends Enum<E>> implements TypeHandler<
public E getResult(CallableStatement cs, int columnIndex) throws SQLException {
return delegate.getResult(cs, columnIndex);
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.handler;
@ -34,9 +34,10 @@ public class Fastjson2TypeHandler extends BaseJsonTypeHandler<Object> {
@Override
protected String toJson(Object object) {
return JSON.toJSONString(object
, JSONWriter.Feature.WriteMapNullValue
, JSONWriter.Feature.WriteNullListAsEmpty
, JSONWriter.Feature.WriteNullStringAsEmpty
, JSONWriter.Feature.WriteMapNullValue
, JSONWriter.Feature.WriteNullListAsEmpty
, JSONWriter.Feature.WriteNullStringAsEmpty
);
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.handler;
@ -34,6 +34,7 @@ public class FastjsonTypeHandler extends BaseJsonTypeHandler<Object> {
@Override
protected String toJson(Object object) {
return JSON.toJSONString(object, SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullStringAsEmpty);
SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullStringAsEmpty);
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.handler;
@ -47,4 +47,5 @@ public class GsonTypeHandler extends BaseJsonTypeHandler<Object> {
public static void setGson(Gson gson) {
GsonTypeHandler.gson = gson;
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.handler;
@ -58,4 +58,5 @@ public class JacksonTypeHandler extends BaseJsonTypeHandler<Object> {
public static void setObjectMapper(ObjectMapper objectMapper) {
JacksonTypeHandler.objectMapper = objectMapper;
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.keygen;
@ -60,8 +60,8 @@ public class CustomKeyGenerator implements KeyGenerator {
private void ensuresKeyGeneratorNotNull() {
if (keyGenerator == null) {
throw FlexExceptions.wrap("The name of \"%s\" key generator not exist.\n" +
"please check annotation @Id(value=\"%s\") at field: %s#%s"
, idInfo.getValue(), idInfo.getValue(), tableInfo.getEntityClass().getName(), idInfo.getProperty());
"please check annotation @Id(value=\"%s\") at field: %s#%s"
, idInfo.getValue(), idInfo.getValue(), tableInfo.getEntityClass().getName(), idInfo.getProperty());
}
}
@ -73,10 +73,10 @@ public class CustomKeyGenerator implements KeyGenerator {
MetaObject metaParam = configuration.newMetaObject(parameter);
Object generateId = keyGenerator.generate(entity, idInfo.getColumn());
try {
MetaObject metaObjectForProperty= metaParam.metaObjectForProperty(FlexConsts.ENTITY);
MetaObject metaObjectForProperty = metaParam.metaObjectForProperty(FlexConsts.ENTITY);
Invoker setInvoker = tableInfo.getReflector().getSetInvoker(idInfo.getProperty());
Object id = ConvertUtil.convert(generateId, setInvoker.getType());
this.setValue(metaObjectForProperty,this.idInfo.getProperty(),id);
this.setValue(metaObjectForProperty, this.idInfo.getProperty(), id);
} catch (Exception e) {
throw FlexExceptions.wrap(e);
}
@ -95,4 +95,5 @@ public class CustomKeyGenerator implements KeyGenerator {
metaParam.setValue(property, value);
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.keygen;
@ -30,4 +30,5 @@ public interface IMultiKeyGenerator {
* @return 列名数组
*/
String[] getKeyColumnNames();
}

View File

@ -24,7 +24,8 @@ import java.util.Map;
public class KeyGeneratorFactory {
private KeyGeneratorFactory() {}
private KeyGeneratorFactory() {
}
private static final Map<String, IKeyGenerator> KEY_GENERATOR_MAP = new HashMap<>();

View File

@ -17,7 +17,8 @@ package com.mybatisflex.core.keygen;
public class KeyGenerators {
private KeyGenerators() {}
private KeyGenerators() {
}
/**
* uuid 主键生成器
@ -36,4 +37,5 @@ public class KeyGenerators {
* {@link com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator}
*/
public static final String snowFlakeId = "snowFlakeId";
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.keygen;
@ -54,4 +54,5 @@ public class MultiEntityKeyGenerator implements KeyGenerator {
// 多条数据批量插入的场景下不支持后设置主键
// 比如 INSERT INTO `tb_account`(uuid,name,sex) VALUES (?, ?, ?), (?, ?, ?)
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.keygen;
@ -55,4 +55,5 @@ public class MultiRowKeyGenerator implements KeyGenerator {
// 多条数据批量插入的场景下不支持后设置主键
// 比如 INSERT INTO `tb_account`(uuid,name,sex) VALUES (?, ?, ?), (?, ?, ?)
}
}

View File

@ -35,7 +35,8 @@ import java.util.List;
public class MybatisKeyGeneratorUtil {
private MybatisKeyGeneratorUtil() {}
private MybatisKeyGeneratorUtil() {
}
public static KeyGenerator createTableKeyGenerator(TableInfo tableInfo, MappedStatement ms) {
List<IdInfo> primaryKeyList = tableInfo.getPrimaryKeyList();
@ -76,30 +77,30 @@ public class MybatisKeyGeneratorUtil {
String sequence = getKeyValue(idInfo, globalKeyConfig);
if (StringUtil.isBlank(sequence)) {
throw FlexExceptions.wrap("Please config sequence by @Id(value=\"...\") for field: %s in class: %s"
, idInfo.getProperty()
, tableInfo.getEntityClass().getName());
, idInfo.getProperty()
, tableInfo.getEntityClass().getName());
}
String selectId = ms.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX;
SqlSource sqlSource = ms.getLang().createSqlSource(ms.getConfiguration(), sequence.trim(), idInfo.getPropertyType());
MappedStatement.Builder msBuilder = new MappedStatement.Builder(ms.getConfiguration(), selectId, sqlSource, SqlCommandType.SELECT)
.resource(ms.getResource())
.fetchSize(null)
.timeout(null)
.statementType(StatementType.PREPARED)
.keyGenerator(NoKeyGenerator.INSTANCE)
.keyProperty(FlexConsts.ENTITY + "." + idInfo.getProperty())
.keyColumn(idInfo.getColumn())
.databaseId(ms.getDatabaseId())
.lang(ms.getLang())
.resultOrdered(false)
.resultSets(null)
.resultMaps(createIdResultMaps(ms.getConfiguration(), selectId + "-Inline", idInfo.getPropertyType(), new ArrayList<>()))
.resultSetType(null)
.flushCacheRequired(false)
.useCache(false)
.cache(ms.getCache());
.resource(ms.getResource())
.fetchSize(null)
.timeout(null)
.statementType(StatementType.PREPARED)
.keyGenerator(NoKeyGenerator.INSTANCE)
.keyProperty(FlexConsts.ENTITY + "." + idInfo.getProperty())
.keyColumn(idInfo.getColumn())
.databaseId(ms.getDatabaseId())
.lang(ms.getLang())
.resultOrdered(false)
.resultSets(null)
.resultMaps(createIdResultMaps(ms.getConfiguration(), selectId + "-Inline", idInfo.getPropertyType(), new ArrayList<>()))
.resultSetType(null)
.flushCacheRequired(false)
.useCache(false)
.cache(ms.getCache());
MappedStatement keyMappedStatement = msBuilder.build();
ms.getConfiguration().addMappedStatement(keyMappedStatement);
@ -115,7 +116,7 @@ public class MybatisKeyGeneratorUtil {
private static List<ResultMap> createIdResultMaps(Configuration configuration,
String statementId, Class<?> resultType, List<ResultMapping> resultMappings) {
ResultMap resultMap = new ResultMap.Builder(configuration, statementId, resultType, resultMappings, null)
.build();
.build();
return Arrays.asList(resultMap);
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.keygen;
@ -68,4 +68,5 @@ public class RowCustomKeyGenerator implements KeyGenerator {
public void processAfter(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
//do nothing
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.keygen;
@ -48,7 +48,7 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
private static final String SECOND_GENERIC_PARAM_NAME = ParamNameResolver.GENERIC_NAME_PREFIX + "2";
private static final String MSG_TOO_MANY_KEYS = "Too many keys are generated. There are only %d target objects. "
+ "You either specified a wrong 'keyProperty' or encountered a driver bug like #1523.";
+ "You either specified a wrong 'keyProperty' or encountered a driver bug like #1523.";
public RowJdbc3KeyGenerator(String keyProperty) {
@ -87,7 +87,7 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
// Multi-param or single param with @Param
assignKeysToParamMap(configuration, rs, rsmd, keyProperties, (Map<String, ?>) parameter);
} else if (parameter instanceof ArrayList && !((ArrayList<?>) parameter).isEmpty()
&& ((ArrayList<?>) parameter).get(0) instanceof ParamMap) {
&& ((ArrayList<?>) parameter).get(0) instanceof ParamMap) {
// Multi-param or single param with @Param in batch operation
assignKeysToParamMapList(configuration, rs, rsmd, keyProperties, (ArrayList<ParamMap<?>>) parameter);
} else {
@ -129,8 +129,8 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
if (assignerList.isEmpty()) {
for (int i = 0; i < keyProperties.length; i++) {
assignerList
.add(getAssignerForParamMap(configuration, rsmd, i + 1, paramMap, keyProperties[i], keyProperties, false)
.getValue());
.add(getAssignerForParamMap(configuration, rsmd, i + 1, paramMap, keyProperties[i], keyProperties, false)
.getValue());
}
}
assignerList.forEach(x -> x.assign(rs, paramMap));
@ -146,9 +146,9 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
Map<String, Entry<Iterator<?>, List<KeyAssigner>>> assignerMap = new HashMap<>();
for (int i = 0; i < keyProperties.length; i++) {
Entry<String, KeyAssigner> entry = getAssignerForParamMap(configuration, rsmd, i + 1, paramMap, keyProperties[i],
keyProperties, true);
keyProperties, true);
Entry<Iterator<?>, List<KeyAssigner>> iteratorPair = MapUtil.computeIfAbsent(assignerMap, entry.getKey(),
k -> MapUtil.entry(collectionize(paramMap.get(k)).iterator(), new ArrayList<>()));
k -> MapUtil.entry(collectionize(paramMap.get(k)).iterator(), new ArrayList<>()));
iteratorPair.getValue().add(entry.getValue());
}
long counter = 0;
@ -176,9 +176,9 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
return getAssignerForSingleParam(config, rsmd, columnPosition, paramMap, keyProperty, omitParamName);
}
throw new ExecutorException("Could not determine which parameter to assign generated keys to. "
+ "Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). "
+ "Specified key properties are " + ArrayUtil.toString(keyProperties) + " and available parameters are "
+ keySet);
+ "Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). "
+ "Specified key properties are " + ArrayUtil.toString(keyProperties) + " and available parameters are "
+ keySet);
}
String paramName = keyProperty.substring(0, firstDot);
if (keySet.contains(paramName)) {
@ -189,9 +189,9 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
return getAssignerForSingleParam(config, rsmd, columnPosition, paramMap, keyProperty, omitParamName);
} else {
throw new ExecutorException("Could not find parameter '" + paramName + "'. "
+ "Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). "
+ "Specified key properties are " + ArrayUtil.toString(keyProperties) + " and available parameters are "
+ keySet);
+ "Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). "
+ "Specified key properties are " + ArrayUtil.toString(keyProperties) + " and available parameters are "
+ keySet);
}
}
@ -219,6 +219,7 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
}
private class KeyAssigner {
private final Configuration configuration;
private final ResultSetMetaData rsmd;
private final TypeHandlerRegistry typeHandlerRegistry;
@ -249,10 +250,10 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
if (metaParam.hasSetter(propertyName)) {
Class<?> propertyType = metaParam.getSetterType(propertyName);
typeHandler = typeHandlerRegistry.getTypeHandler(propertyType,
JdbcType.forCode(rsmd.getColumnType(columnPosition)));
JdbcType.forCode(rsmd.getColumnType(columnPosition)));
} else {
throw new ExecutorException("No setter found for the keyProperty '" + propertyName + "' in '"
+ metaParam.getOriginalObject().getClass().getName() + "'.");
+ metaParam.getOriginalObject().getClass().getName() + "'.");
}
}
if (typeHandler == null) {
@ -263,8 +264,10 @@ public class RowJdbc3KeyGenerator implements KeyGenerator {
}
} catch (SQLException e) {
throw new ExecutorException("Error getting generated key or setting result to parameter object. Cause: " + e,
e);
e);
}
}
}
}

View File

@ -40,6 +40,7 @@ import java.util.Map;
* row 的主键生成器
*/
public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
private static final KeyGenerator[] NO_KEY_GENERATORS = new KeyGenerator[0];
private final MappedStatement ms;
@ -104,23 +105,23 @@ public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
String sequence = rowKey.getValue();
SqlSource sqlSource = ms.getLang().createSqlSource(ms.getConfiguration(), sequence.trim(), Object.class);
MappedStatement.Builder msBuilder = new MappedStatement.Builder(ms.getConfiguration(), selectId, sqlSource, SqlCommandType.SELECT)
.resource(ms.getResource())
.fetchSize(null)
.timeout(null)
.statementType(StatementType.PREPARED)
.keyGenerator(NoKeyGenerator.INSTANCE)
.keyProperty(FlexConsts.ROW + "." + rowKey.getKeyColumn())
.resource(ms.getResource())
.fetchSize(null)
.timeout(null)
.statementType(StatementType.PREPARED)
.keyGenerator(NoKeyGenerator.INSTANCE)
.keyProperty(FlexConsts.ROW + "." + rowKey.getKeyColumn())
// .keyColumn(FlexConsts.ROW + "." + rowKey.getKeyColumn())
.keyColumn(rowKey.getKeyColumn())
.databaseId(ms.getDatabaseId())
.lang(ms.getLang())
.resultOrdered(false)
.resultSets(null)
.resultMaps(new ArrayList<>())
.resultSetType(null)
.flushCacheRequired(false)
.useCache(false)
.cache(ms.getCache());
.keyColumn(rowKey.getKeyColumn())
.databaseId(ms.getDatabaseId())
.lang(ms.getLang())
.resultOrdered(false)
.resultSets(null)
.resultMaps(new ArrayList<>())
.resultSetType(null)
.flushCacheRequired(false)
.useCache(false)
.cache(ms.getCache());
MappedStatement keyMappedStatement = msBuilder.build();
ms.getConfiguration().addMappedStatement(keyMappedStatement);
@ -153,4 +154,5 @@ public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
public String[] getKeyColumnNames() {
return autoKeyGeneratorNames.toArray(new String[0]);
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.keygen.impl;
@ -132,11 +132,11 @@ public class SnowFlakeIDKeyGenerator implements IKeyGenerator {
public SnowFlakeIDKeyGenerator(long workerId, long dataCenterId) {
if (workerId > MAX_WORKER_ID || workerId < 0) {
throw new IllegalArgumentException(
String.format("workerId must be greater than 0 and less than %d.", MAX_WORKER_ID));
String.format("workerId must be greater than 0 and less than %d.", MAX_WORKER_ID));
}
if (dataCenterId > MAX_DATA_CENTER_ID || dataCenterId < 0) {
throw new IllegalArgumentException(
String.format("dataCenterId must be greater than 0 and less than %d.", MAX_DATA_CENTER_ID));
String.format("dataCenterId must be greater than 0 and less than %d.", MAX_DATA_CENTER_ID));
}
this.workerId = workerId;
this.dataCenterId = dataCenterId;
@ -228,9 +228,9 @@ public class SnowFlakeIDKeyGenerator implements IKeyGenerator {
// 时间戳部分 | 数据中心部分 | 机器标识部分 | 序列号部分
return ((currentTimeMillis - twepoch) << TIMESTAMP_SHIFT)
| (dataCenterId << DATA_CENTER_ID_SHIFT)
| (workerId << WORK_ID_SHIFT)
| sequence;
| (dataCenterId << DATA_CENTER_ID_SHIFT)
| (workerId << WORK_ID_SHIFT)
| sequence;
}
/**
@ -244,4 +244,4 @@ public class SnowFlakeIDKeyGenerator implements IKeyGenerator {
return currentTimeMillis;
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.keygen.impl;
@ -25,4 +25,5 @@ public class UUIDKeyGenerator implements IKeyGenerator {
public Object generate(Object entity, String keyColumn) {
return UUID.randomUUID().toString().replace("-", "");
}
}

View File

@ -43,8 +43,8 @@ public abstract class AbstractLogicDeleteProcessor implements LogicDeleteProcess
@Override
public void buildQueryCondition(QueryWrapper queryWrapper, TableInfo tableInfo) {
queryWrapper.and(QueryCondition.create(tableInfo.getSchema(), tableInfo.getTableName(), tableInfo.getLogicDeleteColumn()
, EQUALS
, getLogicNormalValue()));
, EQUALS
, getLogicNormalValue()));
}
/**

View File

@ -26,7 +26,8 @@ public interface LogicDeleteProcessor {
/**
* 用户构建查询正常数据的条件
* @param logicColumn 逻辑删除列
*
* @param logicColumn 逻辑删除列
* @param tableInfo
* @param dialect 数据库方言
*/
@ -34,9 +35,10 @@ public interface LogicDeleteProcessor {
/**
* 用户与构建删除数据时的内容
* @param logicColumn 逻辑删除列
*
* @param logicColumn 逻辑删除列
* @param tableInfo
* @param dialect 数据库方言
* @param dialect 数据库方言
*/
String buildLogicDeletedSet(String logicColumn, TableInfo tableInfo, IDialect dialect);
@ -44,7 +46,7 @@ public interface LogicDeleteProcessor {
* 用于构建通过 {@link QueryWrapper} 查询数据时的内容
*
* @param queryWrapper 条件构造器
* @param tableInfo 表信息
* @param tableInfo 表信息
*/
void buildQueryCondition(QueryWrapper queryWrapper, TableInfo tableInfo);

View File

@ -32,7 +32,7 @@ public class DefaultLogicDeleteProcessor extends AbstractLogicDeleteProcessor {
@Override
public void buildQueryCondition(QueryWrapper queryWrapper, TableInfo tableInfo) {
queryWrapper.where(QueryCondition.create(tableInfo.getSchema(), tableInfo.getTableName(), tableInfo.getLogicDeleteColumn()
, EQUALS, FlexGlobalConfig.getDefaultConfig().getNormalValueOfLogicDelete()));
, EQUALS, FlexGlobalConfig.getDefaultConfig().getNormalValueOfLogicDelete()));
}
@ -40,7 +40,7 @@ public class DefaultLogicDeleteProcessor extends AbstractLogicDeleteProcessor {
protected Object getLogicNormalValue() {
Object normalValueOfLogicDelete = FlexGlobalConfig.getDefaultConfig().getNormalValueOfLogicDelete();
if (normalValueOfLogicDelete instanceof Number
|| normalValueOfLogicDelete instanceof Boolean) {
|| normalValueOfLogicDelete instanceof Boolean) {
return normalValueOfLogicDelete;
}
return SINGLE_QUOTE + normalValueOfLogicDelete + SINGLE_QUOTE;
@ -51,7 +51,7 @@ public class DefaultLogicDeleteProcessor extends AbstractLogicDeleteProcessor {
protected Object getLogicDeletedValue() {
Object deletedValueOfLogicDelete = FlexGlobalConfig.getDefaultConfig().getDeletedValueOfLogicDelete();
if (deletedValueOfLogicDelete instanceof Number
|| deletedValueOfLogicDelete instanceof Boolean) {
|| deletedValueOfLogicDelete instanceof Boolean) {
return deletedValueOfLogicDelete;
}
return SINGLE_QUOTE + deletedValueOfLogicDelete + SINGLE_QUOTE;

View File

@ -24,7 +24,8 @@ import java.util.function.Supplier;
*/
public class MaskManager {
private MaskManager() {}
private MaskManager() {
}
/**
* 脱敏处理器type : processor

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mask;
@ -21,4 +21,5 @@ package com.mybatisflex.core.mask;
public interface MaskProcessor {
Object mask(Object data);
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mask;
@ -33,25 +33,26 @@ public class MaskTypeHandler extends BaseTypeHandler<Object> {
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i,parameter.toString());
ps.setString(i, parameter.toString());
}
@Override
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
String data = rs.getString(columnName);
return MaskManager.mask(maskType,data);
return MaskManager.mask(maskType, data);
}
@Override
public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String data = rs.getString(columnIndex);
return MaskManager.mask(maskType,data);
return MaskManager.mask(maskType, data);
}
@Override
public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String data = cs.getString(columnIndex);
return MaskManager.mask(maskType,data);
return MaskManager.mask(maskType, data);
}
}

View File

@ -20,7 +20,8 @@ package com.mybatisflex.core.mask;
*/
public class Masks {
private Masks() {}
private Masks() {
}
/**
* 手机号脱敏
@ -79,8 +80,8 @@ public class Masks {
private static String mask(String needToMaskString, int keepFirstCount, int keepLastCount, int maskCount) {
return needToMaskString.substring(0, keepFirstCount)
+ createMask(maskCount)
+ needToMaskString.substring(needToMaskString.length() - keepLastCount);
+ createMask(maskCount)
+ needToMaskString.substring(needToMaskString.length() - keepLastCount);
}
@ -183,8 +184,8 @@ public class Masks {
* 密码 脱敏
*/
static MaskProcessor PASSWORD_PROCESSOR = data -> {
if (data instanceof String ) {
return mask((String) data, 0, 0, ((String) data).length()) ;
if (data instanceof String) {
return mask((String) data, 0, 0, ((String) data).length());
}
return data;
};

View File

@ -90,8 +90,8 @@ public class FlexConfiguration extends Configuration {
* {@link SelectKeyGenerator#SELECT_KEY_SUFFIX}
*/
if (!mappedStatementId.endsWith(SelectKeyGenerator.SELECT_KEY_SUFFIX)
&& parameterObject instanceof Map
&& ((Map<?, ?>) parameterObject).containsKey(FlexConsts.SQL_ARGS)) {
&& parameterObject instanceof Map
&& ((Map<?, ?>) parameterObject).containsKey(FlexConsts.SQL_ARGS)) {
SqlArgsParameterHandler sqlArgsParameterHandler = new SqlArgsParameterHandler(mappedStatement, (Map) parameterObject, boundSql);
return (ParameterHandler) interceptorChain.pluginAll(sqlArgsParameterHandler);
} else {
@ -102,9 +102,9 @@ public class FlexConfiguration extends Configuration {
@Override
public ResultSetHandler newResultSetHandler(Executor executor, MappedStatement mappedStatement
, RowBounds rowBounds, ParameterHandler parameterHandler, ResultHandler resultHandler, BoundSql boundSql) {
, RowBounds rowBounds, ParameterHandler parameterHandler, ResultHandler resultHandler, BoundSql boundSql) {
ResultSetHandler resultSetHandler = new FlexResultSetHandler(executor, mappedStatement, parameterHandler,
resultHandler, boundSql, rowBounds);
resultHandler, boundSql, rowBounds);
return (ResultSetHandler) interceptorChain.pluginAll(resultSetHandler);
}
@ -151,7 +151,7 @@ public class FlexConfiguration extends Configuration {
Class<?> asType = MappedStatementTypes.getCurrentType();
if (asType != null) {
return MapUtil.computeIfAbsent(dynamicMappedStatementCache, id + ":" + asType.getName(),
clazz -> replaceResultMap(ms, TableInfoFactory.ofEntityClass(asType))
clazz -> replaceResultMap(ms, TableInfoFactory.ofEntityClass(asType))
);
}
@ -168,12 +168,12 @@ public class FlexConfiguration extends Configuration {
}
//entity insert methods
else if (StringUtil.endsWithAny(ms.getId(), "insert", FlexConsts.METHOD_INSERT_BATCH)
&& ms.getKeyGenerator() == NoKeyGenerator.INSTANCE) {
&& ms.getKeyGenerator() == NoKeyGenerator.INSTANCE) {
ms = replaceEntityKeyGenerator(ms);
}
//entity select
else if (StringUtil.endsWithAny(ms.getId(), "selectOneById", "selectListByIds"
, "selectListByQuery")) {
, "selectListByQuery")) {
ms = replaceResultMap(ms, getTableInfo(ms));
}
@ -200,23 +200,23 @@ public class FlexConfiguration extends Configuration {
}
return new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), ms.getSqlSource(), ms.getSqlCommandType())
.resource(ms.getResource())
.fetchSize(ms.getFetchSize())
.timeout(ms.getTimeout())
.statementType(ms.getStatementType())
.keyGenerator(NoKeyGenerator.INSTANCE)
.keyProperty(ms.getKeyProperties() == null ? null : String.join(",", ms.getKeyProperties()))
.keyColumn(ms.getKeyColumns() == null ? null : String.join(",", ms.getKeyColumns()))
.databaseId(databaseId)
.lang(ms.getLang())
.resultOrdered(ms.isResultOrdered())
.resultSets(ms.getResultSets() == null ? null : String.join(",", ms.getResultSets()))
.resultMaps(Collections.singletonList(resultMap))
.resultSetType(ms.getResultSetType())
.flushCacheRequired(ms.isFlushCacheRequired())
.useCache(ms.isUseCache())
.cache(ms.getCache())
.build();
.resource(ms.getResource())
.fetchSize(ms.getFetchSize())
.timeout(ms.getTimeout())
.statementType(ms.getStatementType())
.keyGenerator(NoKeyGenerator.INSTANCE)
.keyProperty(ms.getKeyProperties() == null ? null : String.join(",", ms.getKeyProperties()))
.keyColumn(ms.getKeyColumns() == null ? null : String.join(",", ms.getKeyColumns()))
.databaseId(databaseId)
.lang(ms.getLang())
.resultOrdered(ms.isResultOrdered())
.resultSets(ms.getResultSets() == null ? null : String.join(",", ms.getResultSets()))
.resultMaps(Collections.singletonList(resultMap))
.resultSetType(ms.getResultSetType())
.flushCacheRequired(ms.isFlushCacheRequired())
.useCache(ms.isUseCache())
.cache(ms.getCache())
.build();
}
/**
@ -238,23 +238,23 @@ public class FlexConfiguration extends Configuration {
}
return new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), ms.getSqlSource(), ms.getSqlCommandType())
.resource(ms.getResource())
.fetchSize(ms.getFetchSize())
.timeout(ms.getTimeout())
.statementType(ms.getStatementType())
.keyGenerator(keyGenerator) // 替换主键生成器
.keyProperty(ms.getKeyProperties() == null ? null : String.join(",", ms.getKeyProperties()))
.keyColumn(ms.getKeyColumns() == null ? null : String.join(",", ms.getKeyColumns()))
.databaseId(databaseId)
.lang(ms.getLang())
.resultOrdered(ms.isResultOrdered())
.resultSets(ms.getResultSets() == null ? null : String.join(",", ms.getResultSets()))
.resultMaps(ms.getResultMaps())
.resultSetType(ms.getResultSetType())
.flushCacheRequired(ms.isFlushCacheRequired())
.useCache(ms.isUseCache())
.cache(ms.getCache())
.build();
.resource(ms.getResource())
.fetchSize(ms.getFetchSize())
.timeout(ms.getTimeout())
.statementType(ms.getStatementType())
.keyGenerator(keyGenerator) // 替换主键生成器
.keyProperty(ms.getKeyProperties() == null ? null : String.join(",", ms.getKeyProperties()))
.keyColumn(ms.getKeyColumns() == null ? null : String.join(",", ms.getKeyColumns()))
.databaseId(databaseId)
.lang(ms.getLang())
.resultOrdered(ms.isResultOrdered())
.resultSets(ms.getResultSets() == null ? null : String.join(",", ms.getResultSets()))
.resultMaps(ms.getResultMaps())
.resultSetType(ms.getResultSetType())
.flushCacheRequired(ms.isFlushCacheRequired())
.useCache(ms.isUseCache())
.cache(ms.getCache())
.build();
}
/**
@ -281,23 +281,23 @@ public class FlexConfiguration extends Configuration {
}
return new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), ms.getSqlSource(), ms.getSqlCommandType())
.resource(ms.getResource())
.fetchSize(ms.getFetchSize())
.timeout(ms.getTimeout())
.statementType(ms.getStatementType())
.keyGenerator(keyGenerator) // 替换主键生成器
.keyProperty(tableInfo.getKeyProperties())
.keyColumn(tableInfo.getKeyColumns())
.databaseId(databaseId)
.lang(ms.getLang())
.resultOrdered(ms.isResultOrdered())
.resultSets(ms.getResultSets() == null ? null : String.join(",", ms.getResultSets()))
.resultMaps(ms.getResultMaps())
.resultSetType(ms.getResultSetType())
.flushCacheRequired(ms.isFlushCacheRequired())
.useCache(ms.isUseCache())
.cache(ms.getCache())
.build();
.resource(ms.getResource())
.fetchSize(ms.getFetchSize())
.timeout(ms.getTimeout())
.statementType(ms.getStatementType())
.keyGenerator(keyGenerator) // 替换主键生成器
.keyProperty(tableInfo.getKeyProperties())
.keyColumn(tableInfo.getKeyColumns())
.databaseId(databaseId)
.lang(ms.getLang())
.resultOrdered(ms.isResultOrdered())
.resultSets(ms.getResultSets() == null ? null : String.join(",", ms.getResultSets()))
.resultMaps(ms.getResultMaps())
.resultSetType(ms.getResultSetType())
.flushCacheRequired(ms.isFlushCacheRequired())
.useCache(ms.isUseCache())
.cache(ms.getCache())
.build();
}
@ -337,8 +337,9 @@ public class FlexConfiguration extends Configuration {
public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
T mapper = super.getMapper(type, sqlSession);
return (T) Proxy.newProxyInstance(type.getClassLoader()
, new Class[]{type}
, new MapperInvocationHandler(mapper, this));
, new Class[]{type}
, new MapperInvocationHandler(mapper, this));
}
}

View File

@ -32,7 +32,7 @@ import java.util.Iterator;
public class FlexResultSetHandler extends DefaultResultSetHandler {
public FlexResultSetHandler(Executor executor, MappedStatement mappedStatement, ParameterHandler parameterHandler
, ResultHandler<?> resultHandler, BoundSql boundSql, RowBounds rowBounds) {
, ResultHandler<?> resultHandler, BoundSql boundSql, RowBounds rowBounds) {
super(executor, mappedStatement, parameterHandler, resultHandler, boundSql, rowBounds);
}
@ -87,5 +87,7 @@ public class FlexResultSetHandler extends DefaultResultSetHandler {
public Iterator<T> iterator() {
return originalCursor.iterator();
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mybatis;
@ -101,11 +101,11 @@ public class FlexSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
return;
}
String banner = " __ __ _ _ _ _____ _ \n" +
" | \\/ |_ _| |__ __ _| |_(_)___ | ___| | _____ __\n" +
" | |\\/| | | | | '_ \\ / _` | __| / __| | |_ | |/ _ \\ \\/ /\n" +
" | | | | |_| | |_) | (_| | |_| \\__ \\ | _| | | __/> < \n" +
" |_| |_|\\__, |_.__/ \\__,_|\\__|_|___/ |_| |_|\\___/_/\\_\\\n" +
" |___/ v" + FlexConsts.VERSION + " https://mybatis-flex.com";
" | \\/ |_ _| |__ __ _| |_(_)___ | ___| | _____ __\n" +
" | |\\/| | | | | '_ \\ / _` | __| / __| | |_ | |/ _ \\ \\/ /\n" +
" | | | | |_| | |_) | (_| | |_| \\__ \\ | _| | | __/> < \n" +
" |_| |_|\\__, |_.__/ \\__,_|\\__|_|___/ |_| |_|\\___/_/\\_\\\n" +
" |___/ v" + FlexConsts.VERSION + " https://mybatis-flex.com";
System.out.println(banner);
}

View File

@ -92,19 +92,19 @@ public class FlexStatementHandler implements StatementHandler {
@Override
public int update(Statement statement) throws SQLException {
return auditEnable ? AuditManager.startAudit(() -> delegate.update(statement), statement, boundSql, configuration)
: delegate.update(statement);
: delegate.update(statement);
}
@Override
public <E> List<E> query(Statement statement, ResultHandler resultHandler) throws SQLException {
return auditEnable ? AuditManager.startAudit(() -> delegate.query(statement, resultHandler), statement, boundSql, configuration)
: delegate.query(statement, resultHandler);
: delegate.query(statement, resultHandler);
}
@Override
public <E> Cursor<E> queryCursor(Statement statement) throws SQLException {
return auditEnable ? AuditManager.startAudit(() -> delegate.queryCursor(statement), statement, boundSql, configuration)
: delegate.queryCursor(statement);
: delegate.queryCursor(statement);
}
@Override

View File

@ -17,19 +17,20 @@ package com.mybatisflex.core.mybatis;
public class MappedStatementTypes {
private MappedStatementTypes() {}
private MappedStatementTypes() {
}
private static ThreadLocal<Class<?>> currentTypeTL = new ThreadLocal<>();
public static void setCurrentType(Class<?> type){
public static void setCurrentType(Class<?> type) {
currentTypeTL.set(type);
}
public static Class<?> getCurrentType(){
public static Class<?> getCurrentType() {
return currentTypeTL.get();
}
public static void clear(){
public static void clear() {
currentTypeTL.remove();
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mybatis;
@ -90,4 +90,5 @@ public class SqlArgsParameterHandler extends DefaultParameterHandler {
ps.setTimestamp(index, new java.sql.Timestamp(value.getTime()));
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mybatis;
@ -37,4 +37,5 @@ public class TypeHandlerObject implements Serializable {
public void setParameter(PreparedStatement ps, int i) throws SQLException {
typeHandler.setParameter(ps, i, value, jdbcType);
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mybatis.executor;
@ -23,10 +23,11 @@ import java.util.Map;
public interface CacheKeyBuilder {
default CacheKey buildCacheKey(CacheKey cacheKey, Object parameterObject){
if (parameterObject instanceof Map && ((Map) parameterObject).containsKey(FlexConsts.SQL_ARGS)){
default CacheKey buildCacheKey(CacheKey cacheKey, Object parameterObject) {
if (parameterObject instanceof Map && ((Map) parameterObject).containsKey(FlexConsts.SQL_ARGS)) {
cacheKey.update(Arrays.toString((Object[]) ((Map<?, ?>) parameterObject).get(FlexConsts.SQL_ARGS)));
}
return cacheKey;
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mybatis.executor;
@ -106,7 +106,7 @@ public class FlexBatchExecutor extends BatchExecutor implements CacheKeyBuilder
// 修复批量插入并设置主键时出错
// fixed https://gitee.com/mybatis-flex/mybatis-flex/issues/I6Y8ZU
else if (RowKeyGenerator.class.equals(keyGenerator.getClass())
&& ((RowKeyGenerator) keyGenerator).hasGeneratedKeys()) {
&& ((RowKeyGenerator) keyGenerator).hasGeneratedKeys()) {
keyGenerator.processAfter(this, ms, stmt, parameterObjects);
}
// issue #141
@ -120,14 +120,14 @@ public class FlexBatchExecutor extends BatchExecutor implements CacheKeyBuilder
} catch (BatchUpdateException e) {
StringBuilder message = new StringBuilder();
message.append(batchResult.getMappedStatement().getId())
.append(" (batch index #")
.append(i + 1)
.append(")")
.append(" failed.");
.append(" (batch index #")
.append(i + 1)
.append(")")
.append(" failed.");
if (i > 0) {
message.append(" ")
.append(i)
.append(" prior sub executor(s) completed successfully, but will be rolled back.");
.append(i)
.append(" prior sub executor(s) completed successfully, but will be rolled back.");
}
throw new BatchExecutorException(message.toString(), e, results, batchResult);
}
@ -143,4 +143,5 @@ public class FlexBatchExecutor extends BatchExecutor implements CacheKeyBuilder
batchResultList.clear();
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mybatis.executor;
@ -31,6 +31,7 @@ public class FlexReuseExecutor extends ReuseExecutor implements CacheKeyBuilder
@Override
public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
return buildCacheKey(super.createCacheKey(ms, parameterObject, rowBounds, boundSql),parameterObject);
return buildCacheKey(super.createCacheKey(ms, parameterObject, rowBounds, boundSql), parameterObject);
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.mybatis.executor;
@ -31,6 +31,7 @@ public class FlexSimpleExecutor extends SimpleExecutor implements CacheKeyBuilde
@Override
public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
return buildCacheKey(super.createCacheKey(ms, parameterObject, rowBounds, boundSql),parameterObject);
return buildCacheKey(super.createCacheKey(ms, parameterObject, rowBounds, boundSql), parameterObject);
}
}

View File

@ -70,7 +70,6 @@ public class Page<T> implements Serializable {
}
/**
* 获取当前页的数据
*
@ -270,11 +269,12 @@ public class Page<T> implements Serializable {
@Override
public String toString() {
return "Page{" +
"pageNumber=" + pageNumber +
", pageSize=" + pageSize +
", totalPage=" + totalPage +
", totalRow=" + totalRow +
", records=" + records +
'}';
"pageNumber=" + pageNumber +
", pageSize=" + pageSize +
", totalPage=" + totalPage +
", totalRow=" + totalRow +
", records=" + records +
'}';
}
}

View File

@ -303,7 +303,7 @@ public class EntitySqlProvider {
//优先构建 sql再构建参数
String sql = DialectFactory.getDialect().forUpdateNumberAddByQuery(tableInfo.getSchema()
, tableInfo.getTableName(), fieldName, value, queryWrapper);
, tableInfo.getTableName(), fieldName, value, queryWrapper);
Object[] queryParams = CPI.getValueArray(queryWrapper);
ProviderUtil.setSqlArgs(params, queryParams);

View File

@ -270,7 +270,7 @@ public class RowSqlProvider {
//优先构建 sql再构建参数
String sql = DialectFactory.getDialect().forUpdateNumberAddByQuery(schema
, tableName, fieldName, value, queryWrapper);
, tableName, fieldName, value, queryWrapper);
Object[] queryParams = CPI.getValueArray(queryWrapper);
ProviderUtil.setSqlArgs(params, queryParams);

View File

@ -147,5 +147,7 @@ public class ArithmeticQueryColumn extends QueryColumn {
throw FlexExceptions.wrap(e);
}
}
}
}

View File

@ -127,8 +127,8 @@ public class BaseQueryWrapper<T extends BaseQueryWrapper<T>> implements CloneSup
joinTables.add(queryTable);
}
protected void addEndFragment(String fragment){
if (endFragments == null){
protected void addEndFragment(String fragment) {
if (endFragments == null) {
endFragments = new ArrayList<>();
}
endFragments.add(fragment);
@ -251,14 +251,14 @@ public class BaseQueryWrapper<T extends BaseQueryWrapper<T>> implements CloneSup
this.context = context;
}
protected void putContext(String key, Object value){
if (context == null){
protected void putContext(String key, Object value) {
if (context == null) {
context = new HashMap<>();
}
context.put(key,value);
context.put(key, value);
}
protected <R> R getContext(String key){
protected <R> R getContext(String key) {
return context == null ? null : (R) context.get(key);
}
@ -278,11 +278,11 @@ public class BaseQueryWrapper<T extends BaseQueryWrapper<T>> implements CloneSup
clone.orderBys = CollectionUtil.cloneArrayList(this.orderBys);
clone.unions = CollectionUtil.cloneArrayList(this.unions);
// copy List if necessary ...
if (this.endFragments != null){
if (this.endFragments != null) {
clone.endFragments = CollectionUtil.newArrayList(this.endFragments);
}
// copy Map if necessary ...
if (this.context != null){
if (this.context != null) {
clone.context = CollectionUtil.newHashMap(this.context);
}
return clone;
@ -290,4 +290,5 @@ public class BaseQueryWrapper<T extends BaseQueryWrapper<T>> implements CloneSup
throw FlexExceptions.wrap(e);
}
}
}
}

View File

@ -112,8 +112,8 @@ public class Brackets extends QueryCondition {
@Override
public String toString() {
return "Brackets{" +
"childCondition=" + childCondition +
'}';
"childCondition=" + childCondition +
'}';
}
@Override
@ -123,4 +123,5 @@ public class Brackets extends QueryCondition {
clone.childCondition = ObjectUtil.clone(this.childCondition);
return clone;
}
}

View File

@ -42,7 +42,6 @@ public class CPI {
}
public static With getWith(QueryWrapper queryWrapper) {
return queryWrapper.with;
}
@ -81,8 +80,8 @@ public class CPI {
public static void setSelectColumnsIfNecessary(QueryWrapper queryWrapper, List<QueryColumn> selectColumns) {
if (CollectionUtil.isEmpty(queryWrapper.getSelectColumns())
&& CollectionUtil.isNotEmpty(selectColumns)
&& CollectionUtil.isEmpty(CPI.getJoinTables(queryWrapper))
&& CollectionUtil.isNotEmpty(selectColumns)
&& CollectionUtil.isEmpty(CPI.getJoinTables(queryWrapper))
) {
queryWrapper.setSelectColumns(selectColumns);
}
@ -212,14 +211,14 @@ public class CPI {
public static void setFromIfNecessary(QueryWrapper queryWrapper, String tableName) {
if (StringUtil.isNotBlank(tableName)
&& CollectionUtil.isEmpty(queryWrapper.getQueryTables())) {
&& CollectionUtil.isEmpty(queryWrapper.getQueryTables())) {
queryWrapper.from(tableName);
}
}
public static void setFromIfNecessary(QueryWrapper queryWrapper, String schema, String tableName) {
if (StringUtil.isNotBlank(tableName)
&& CollectionUtil.isEmpty(queryWrapper.getQueryTables())) {
&& CollectionUtil.isEmpty(queryWrapper.getQueryTables())) {
queryWrapper.from(new QueryTable(schema, tableName));
}
}
@ -235,4 +234,5 @@ public class CPI {
public static boolean isSameTable(QueryTable queryTable, QueryTable otherTable) {
return queryTable.isSameTable(otherTable);
}
}

View File

@ -91,6 +91,7 @@ public class CaseQueryColumn extends QueryColumn implements HasParamsColumn {
public static class When implements CloneSupport<When> {
private QueryCondition whenCondition;
private Object thenValue;
@ -114,6 +115,7 @@ public class CaseQueryColumn extends QueryColumn implements HasParamsColumn {
throw FlexExceptions.wrap(e);
}
}
}
public static class Builder {
@ -148,6 +150,9 @@ public class CaseQueryColumn extends QueryColumn implements HasParamsColumn {
this.builder.caseQueryColumn.addWhen(builder.lastWhen);
return builder;
}
}
}
}

View File

@ -91,6 +91,7 @@ public class CaseSearchQueryColumn extends QueryColumn implements HasParamsColum
public static class When implements CloneSupport<When> {
private Object searchValue;
private Object thenValue;
@ -114,6 +115,7 @@ public class CaseSearchQueryColumn extends QueryColumn implements HasParamsColum
throw FlexExceptions.wrap(e);
}
}
}
@ -153,6 +155,9 @@ public class CaseSearchQueryColumn extends QueryColumn implements HasParamsColum
this.builder.caseQueryColumn.addWhen(builder.lastWhen);
return builder;
}
}
}
}

View File

@ -37,7 +37,7 @@ public class DistinctQueryColumn extends QueryColumn {
}
String sql = SqlConsts.DISTINCT + StringUtil.join(SqlConsts.DELIMITER, queryColumns, queryColumn ->
queryColumn.toSelectSql(queryTables, dialect));
queryColumn.toSelectSql(queryTables, dialect));
return sql + WrapperUtil.buildAlias(alias, dialect);
}
@ -50,7 +50,7 @@ public class DistinctQueryColumn extends QueryColumn {
}
return SqlConsts.DISTINCT + StringUtil.join(SqlConsts.DELIMITER, queryColumns, queryColumn ->
queryColumn.toSelectSql(queryTables, dialect));
queryColumn.toSelectSql(queryTables, dialect));
}
@ -61,4 +61,5 @@ public class DistinctQueryColumn extends QueryColumn {
clone.queryColumns = CollectionUtil.cloneArrayList(this.queryColumns);
return clone;
}
}

View File

@ -121,9 +121,9 @@ public class FunctionQueryColumn extends QueryColumn implements HasParamsColumn
}
String sql = columns.stream()
.filter(Objects::nonNull)
.map(c -> c.toSelectSql(queryTables, dialect))
.collect(Collectors.joining(SqlConsts.DELIMITER));
.filter(Objects::nonNull)
.map(c -> c.toSelectSql(queryTables, dialect))
.collect(Collectors.joining(SqlConsts.DELIMITER));
if (StringUtil.isBlank(sql)) {
return SqlConsts.EMPTY;
@ -133,13 +133,12 @@ public class FunctionQueryColumn extends QueryColumn implements HasParamsColumn
}
@Override
public String toString() {
return "FunctionQueryColumn{" +
"fnName='" + fnName + '\'' +
", columns=" + columns +
'}';
"fnName='" + fnName + '\'' +
", columns=" + columns +
'}';
}
@Override

View File

@ -1,6 +1,23 @@
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.query;
public interface HasParamsColumn {
Object[] getParamValues();
}

View File

@ -42,8 +42,8 @@ public class IfFunctionQueryColumn extends QueryColumn implements HasParamsColum
@Override
String toConditionSql(List<QueryTable> queryTables, IDialect dialect) {
return "IF(" + condition.toSql(queryTables, dialect) + ", " +
trueValue.toConditionSql(queryTables, dialect) + ", " +
falseValue.toConditionSql(queryTables, dialect) + ")";
trueValue.toConditionSql(queryTables, dialect) + ", " +
falseValue.toConditionSql(queryTables, dialect) + ")";
}
@Override
@ -71,4 +71,4 @@ public class IfFunctionQueryColumn extends QueryColumn implements HasParamsColum
return clone;
}
}
}

View File

@ -100,4 +100,5 @@ public class Join implements CloneSupport<Join> {
throw FlexExceptions.wrap(e);
}
}
}

View File

@ -1,17 +1,17 @@
/**
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.core.query;
@ -52,5 +52,6 @@ public class Joiner<M> {
join.on(newWrapper.whereQueryCondition);
return queryWrapper;
}
}

View File

@ -49,9 +49,9 @@ public class OperatorQueryCondition extends QueryCondition {
sql.append(prevEffectiveCondition.connector);
}
sql.append(operator)
.append(SqlConsts.BRACKET_LEFT)
.append(childSql)
.append(SqlConsts.BRACKET_RIGHT);
.append(SqlConsts.BRACKET_LEFT)
.append(childSql)
.append(SqlConsts.BRACKET_RIGHT);
}
}
@ -82,4 +82,5 @@ public class OperatorQueryCondition extends QueryCondition {
clone.childCondition = ObjectUtil.clone(this.childCondition);
return clone;
}
}

View File

@ -28,6 +28,7 @@ import java.util.List;
* 示例2and not EXISTS (select ... from ... where ....)
*/
public class OperatorSelectCondition extends QueryCondition {
//操作符例如 exist, not exist
private final String operator;
private QueryWrapper queryWrapper;
@ -51,9 +52,9 @@ public class OperatorSelectCondition extends QueryCondition {
sql.append(prevEffectiveCondition.connector);
}
sql.append(operator)
.append(SqlConsts.BRACKET_LEFT)
.append(childSql)
.append(SqlConsts.BRACKET_RIGHT);
.append(SqlConsts.BRACKET_LEFT)
.append(childSql)
.append(SqlConsts.BRACKET_RIGHT);
}
}
@ -82,4 +83,5 @@ public class OperatorSelectCondition extends QueryCondition {
clone.queryWrapper = ObjectUtil.clone(this.queryWrapper);
return clone;
}
}

View File

@ -571,10 +571,10 @@ public class QueryColumn implements CloneSupport<QueryColumn> {
@Override
public String toString() {
return "QueryColumn{" +
"table=" + table +
", name='" + name + '\'' +
", alias='" + alias + '\'' +
'}';
"table=" + table +
", name='" + name + '\'' +
", alias='" + alias + '\'' +
'}';
}
@ -589,4 +589,5 @@ public class QueryColumn implements CloneSupport<QueryColumn> {
throw FlexExceptions.wrap(e);
}
}
}

View File

@ -182,8 +182,8 @@ public class QueryCondition implements CloneSupport<QueryCondition> {
//子查询
else if (value instanceof QueryWrapper) {
sql.append(SqlConsts.BRACKET_LEFT)
.append(dialect.buildSelectSql((QueryWrapper) value))
.append(SqlConsts.BRACKET_RIGHT);
.append(dialect.buildSelectSql((QueryWrapper) value))
.append(SqlConsts.BRACKET_RIGHT);
}
//原生sql
else if (value instanceof RawFragment) {
@ -214,10 +214,10 @@ public class QueryCondition implements CloneSupport<QueryCondition> {
protected void appendQuestionMark(StringBuilder sqlBuilder) {
//noinspection StatementWithEmptyBody
if (SqlConsts.IS_NULL.equals(logic)
|| SqlConsts.IS_NOT_NULL.equals(logic)
|| value instanceof QueryColumn
|| value instanceof QueryWrapper
|| value instanceof RawFragment) {
|| SqlConsts.IS_NOT_NULL.equals(logic)
|| value instanceof QueryColumn
|| value instanceof QueryWrapper
|| value instanceof RawFragment) {
//do nothing
}
@ -278,11 +278,11 @@ public class QueryCondition implements CloneSupport<QueryCondition> {
@Override
public String toString() {
return "QueryCondition{" +
"column=" + column +
", logic='" + logic + '\'' +
", value=" + value +
", effective=" + effective +
'}';
"column=" + column +
", logic='" + logic + '\'' +
", value=" + value +
", effective=" + effective +
'}';
}
@Override
@ -302,4 +302,5 @@ public class QueryCondition implements CloneSupport<QueryCondition> {
throw FlexExceptions.wrap(e);
}
}
}

View File

@ -84,4 +84,5 @@ public class QueryOrderBy implements CloneSupport<QueryOrderBy> {
throw FlexExceptions.wrap(e);
}
}
}

View File

@ -86,8 +86,8 @@ public class QueryTable implements CloneSupport<QueryTable> {
return false;
}
if (StringUtil.isNotBlank(alias)
&& StringUtil.isNotBlank(table.alias)
&& (Objects.equals(alias, table.alias))) {
&& StringUtil.isNotBlank(table.alias)
&& (Objects.equals(alias, table.alias))) {
return false;
}
return Objects.equals(name, table.name);
@ -112,10 +112,10 @@ public class QueryTable implements CloneSupport<QueryTable> {
@Override
public String toString() {
return "QueryTable{" +
"schema='" + schema + '\'' +
", name='" + name + '\'' +
", alias='" + alias + '\'' +
'}';
"schema='" + schema + '\'' +
", name='" + name + '\'' +
", alias='" + alias + '\'' +
'}';
}
@Override
@ -126,4 +126,5 @@ public class QueryTable implements CloneSupport<QueryTable> {
throw FlexExceptions.wrap(e);
}
}
}

Some files were not shown because too many files have changed in this diff Show More