diff --git a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DataSourceHolder.java b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DataSourceHolder.java index d965d882b..c6682e32b 100644 --- a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DataSourceHolder.java +++ b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DataSourceHolder.java @@ -33,13 +33,8 @@ public class DataSourceHolder { public void init(DataSource dataSource) throws SQLException { if (null != dataSource) { - Connection connection = null; - try { - connection = dataSource.getConnection(); + try (Connection connection = dataSource.getConnection()) { install(dataSource, DatabaseType.fromJdbcUrl(connection.getMetaData().getURL())); - } finally { - if (null != connection) - connection.close(); } } } @@ -83,7 +78,7 @@ public class DataSourceHolder { public static void install(DataSource dataSource, DatabaseType databaseType) { if (DataSourceHolder.defaultDataSource != null) { - return; + return; } DataSourceHolder.defaultDataSource = dataSource; DataSourceHolder.defaultDatabaseType = databaseType; diff --git a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DynamicDataSource.java b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DynamicDataSource.java index 9e589925d..d1c5598c0 100644 --- a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DynamicDataSource.java +++ b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DynamicDataSource.java @@ -64,7 +64,7 @@ public interface DynamicDataSource extends DataSource { * @param rememberLast 是否记住上一次选中的数据源 */ static void useDefault(boolean rememberLast) { - if (getActiveDataSourceId() != null && rememberLast) + if (rememberLast && null != getActiveDataSourceId()) ThreadLocalUtils.put(DATA_SOURCE_FLAG_LAST, getActiveDataSourceId()); ThreadLocalUtils.remove(DATA_SOURCE_FLAG); } diff --git a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/SqlBuilder.java b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/SqlBuilder.java index 2919934bd..99fb71acc 100644 --- a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/SqlBuilder.java +++ b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/SqlBuilder.java @@ -22,13 +22,7 @@ package org.hswebframework.web.dao.mybatis.builder; * @author zhouhao */ public class SqlBuilder { - private static boolean dynamic; - public static final Object current() { return EasyOrmSqlBuilder.getInstance(); } - - public static void setDynamic(boolean dynamic) { - SqlBuilder.dynamic = dynamic; - } } diff --git a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/CloneableEntity.java b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/CloneableEntity.java index bcb2761b6..09ec4a6b3 100644 --- a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/CloneableEntity.java +++ b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/CloneableEntity.java @@ -6,5 +6,5 @@ package org.hswebframework.web.commons.entity; * @author zhouhao */ public interface CloneableEntity extends Entity, Cloneable { - T clone(); + CloneableEntity clone(); } diff --git a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/GenericEntity.java b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/GenericEntity.java index 94a685aa3..c64793fcb 100644 --- a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/GenericEntity.java +++ b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/GenericEntity.java @@ -38,6 +38,7 @@ public interface GenericEntity extends CloneableEntity { void setProperties(Map properties); + @SuppressWarnings("unchecked") default T getProperty(String propertyName, T defaultValue) { Map map = getProperties(); if (map == null) return null; diff --git a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/SimpleGenericEntity.java b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/SimpleGenericEntity.java index 00932a13f..688eebd0f 100644 --- a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/SimpleGenericEntity.java +++ b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/SimpleGenericEntity.java @@ -70,5 +70,5 @@ public abstract class SimpleGenericEntity implements GenericEntity { } @Override - public abstract SimpleGenericEntity clone(); + public abstract CloneableEntity clone(); } diff --git a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java index 1dc44d14d..de395fe7a 100644 --- a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java +++ b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java @@ -61,6 +61,7 @@ public class MapperEntityFactory implements EntityFactory { realTypeMapper.put(beanClass, mapper); return mapper.getInstanceGetter().get(); } catch (ClassNotFoundException e) { + throw new NotFoundException(e.getMessage()); } } } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java index 9b887be7a..928052a34 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java @@ -48,4 +48,5 @@ public interface UserEntity extends UserReadEntity, GenericEntity { void setLastLoginIp(String lastLoginIp); + UserEntity clone(); } diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-service/hsweb-system-config-service-simple/src/test/java/org/hswebframework/web/service/config/ConfigServiceTests.java b/hsweb-system/hsweb-system-config/hsweb-system-config-service/hsweb-system-config-service-simple/src/test/java/org/hswebframework/web/service/config/ConfigServiceTests.java deleted file mode 100644 index ee8c2475f..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-service/hsweb-system-config-service-simple/src/test/java/org/hswebframework/web/service/config/ConfigServiceTests.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.service.config; - -import org.hswebframework.web.service.config.simple.SimpleConfigService; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class ConfigServiceTests { - public static void main(String[] args) { - SimpleConfigService configService =new SimpleConfigService(); -// System.out.println(new SimpleConfigService().createEntity()); - } -}