Skip to content

Commit 7cc6737

Browse files
committed
优化单个connection的获取,添加getconnection busy的提示,针对track支持复杂类型 0.9.9
1 parent bf15bf3 commit 7cc6737

File tree

15 files changed

+28
-42
lines changed

15 files changed

+28
-42
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.easy-query</groupId>
88
<artifactId>easy-query-all</artifactId>
99
<packaging>pom</packaging>
10-
<version>0.9.8</version>
10+
<version>0.9.9</version>
1111
<name>easy-query</name>
1212
<description>java object query distributed connector</description>
1313
<url>https://github.com/xuejmnet/easy-query</url>

samples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>easy-query-all</artifactId>
77
<groupId>com.easy-query</groupId>
8-
<version>0.9.8</version>
8+
<version>0.9.9</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

samples/springbootdemo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<dependency>
4646
<groupId>com.easy-query</groupId>
4747
<artifactId>sql-springboot-starter</artifactId>
48-
<version>0.9.8</version>
48+
<version>0.9.9</version>
4949
<scope>compile</scope>
5050
</dependency>
5151
<dependency>

sql-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>easy-query-all</artifactId>
77
<groupId>com.easy-query</groupId>
8-
<version>0.9.8</version>
8+
<version>0.9.9</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

sql-core/src/main/java/com/easy/query/core/basic/plugin/track/DefaultTrackContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private Object createAndCopyValue(Object entity, EntityMetadata entityMetadata){
112112
Class<?> propertyType = columnMetadata.getPropertyType();
113113
Property<Object, ?> beanGetter = fastBean.getBeanGetter(property);
114114
Object value = beanGetter.apply(entity);
115-
if(EasyClassUtil.isBasicType(propertyType)){
115+
if(EasyClassUtil.isBasicType(propertyType)||EasyClassUtil.isEnumType(propertyType)){
116116

117117
beanSetter.call(original,value);
118118
}else{

sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceUnit.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ protected List<Connection> getConnections(int count) throws SQLException {
9898
protected SemaphoreReleaseOnlyOnce tryAcquire(int count, long timeout, TimeUnit unit) {
9999

100100
try {
101-
long startTime =warningBusy? System.currentTimeMillis():0L;
101+
long startTime = warningBusy ? System.currentTimeMillis() : 0L;
102102
boolean acquire = semaphore.tryAcquire(count, timeout, unit);
103103
if (acquire) {
104104
if (warningBusy) {
105105
long endTime = System.currentTimeMillis();
106106
long constTime = endTime - startTime;
107-
if (constTime > (unit.toMillis(timeout) * 0.8)) {
108-
log.warn("get connection is busy. you can try increasing the connection pool size or reducing the number of access requests.");
107+
long timeoutMillis = unit.toMillis(timeout);
108+
if (constTime >= (timeoutMillis * 0.8)) {
109+
log.warn("get connection use time:" + constTime + "(ms),timeout:" + timeoutMillis + "(ms). you can try increasing the connection pool size or reducing the number of access requests.");
109110
}
110111
}
111112
return new SemaphoreReleaseOnlyOnce(count, semaphore);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.easy.query.core.expression.segment.factory;
2+
3+
/**
4+
* create time 2023/5/28 22:26
5+
* 文件说明
6+
*
7+
* @author xuejiaming
8+
*/
9+
public interface SQLSegmentFactory {
10+
}

sql-core/src/main/java/com/easy/query/core/expression/sql/TableContext.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,10 @@ public void addTable(TableAvailable table) {
2828
aliasMapping.put(table, new TableAliasSchema(table, size));
2929
}
3030

31-
public String getTableAlias(TableAvailable table, String alias) {
32-
if (table == null) {
33-
throw new IllegalArgumentException("table is null");
34-
}
35-
int mappingSize = aliasMapping.size();
36-
if (mappingSize == 0) {
37-
return null;
38-
}
39-
if (mappingSize == 1) {
40-
TableAliasSchema tableAliasSchema = getTableAliasSchema(table);
41-
if (tableAliasSchema.getTable().isAnonymous()||tableAliasSchema.getTable().hasAlias()) {
42-
return tableAliasSchema.getTableAlias(alias);
43-
}
44-
return null;
45-
}
46-
return getTableAliasSchema(table).getTableAlias(alias);
47-
}
48-
4931
public boolean isEmpty() {
5032
return aliasMapping.isEmpty();
5133
}
5234

53-
public TableAliasSchema getTableAliasSchema(TableAvailable table) {
54-
55-
TableAliasSchema tableAliasSchema = aliasMapping.get(table);
56-
if (tableAliasSchema == null) {
57-
throw new EasyQueryInvalidOperationException("unknown table:" + EasyClassUtil.getSimpleName(table.getEntityClass()) + "." + table.getTableName());
58-
}
59-
return tableAliasSchema;
60-
}
61-
6235
public void copyTo(TableContext tableContext){
6336
for (Map.Entry<TableAvailable, TableAliasSchema> aliasSchemaEntry : aliasMapping.entrySet()) {
6437
tableContext.addTable(aliasSchemaEntry.getKey());

sql-core/src/main/java/com/easy/query/core/util/EasyClassUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ public static boolean isBasicType(Class<?> clazz) {
105105
} else {
106106
return false;
107107
}
108-
108+
}
109+
public static boolean isEnumType(Class<?> clazz) {
110+
return clazz.isEnum();
109111
}
110112

111113
public static <T> T newInstance(Class<T> clazz) {

sql-h2/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.easy-query</groupId>
88
<artifactId>easy-query-all</artifactId>
9-
<version>0.9.8</version>
9+
<version>0.9.9</version>
1010
</parent>
1111

1212
<artifactId>sql-h2</artifactId>

0 commit comments

Comments
 (0)