Skip to content

Commit 49dc828

Browse files
committed
👶 update to sql2o-plus 1.0.3-SNAPSHOT ✔️
1.新增获取表字段名
1 parent 3d2cf76 commit 49dc828

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,13 @@ db.isDebug(true);
450450
Database指定isDebug(true)后,查询结果属性不能匹配会抛出异常信息,[例子](src/test/java/com/sqltest/db/DebugTest.java)
451451

452452

453+
## 获取表字段名
454+
455+
```java
456+
Sql2oUtils.getColumnName(UserInfo::getId);
457+
// 输出
458+
user_id
459+
```
453460

454461
## 其他
455462

src/main/java/io/github/cotide/dapper/core/unit/Sql2oUtils.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import io.github.cotide.dapper.basic.enums.IEnum;
77
import io.github.cotide.dapper.basic.enums.IntegerEnum;
88
import io.github.cotide.dapper.basic.enums.StringEnum;
9+
import io.github.cotide.dapper.core.functions.TypeFunction;
910
import io.github.cotide.dapper.exceptions.SqlBuildException;
11+
import io.github.cotide.dapper.query.Sql;
1012
import lombok.AccessLevel;
1113
import lombok.NoArgsConstructor;
1214

@@ -21,6 +23,19 @@
2123
public class Sql2oUtils {
2224

2325

26+
/**
27+
* 获取字段名
28+
* @param function
29+
* @param <T>
30+
* @param <R>
31+
* @return
32+
*/
33+
public static <T extends Entity, R> String getColumnName(TypeFunction<T, R> function) {
34+
35+
return Sql2oUtils.getLambdaColumnName(function);
36+
}
37+
38+
2439
public static String getLambdaColumnName(Serializable lambda) {
2540
for (Class<?> cl = lambda.getClass(); cl != null; cl = cl.getSuperclass()) {
2641
try {

0 commit comments

Comments
 (0)