File tree Expand file tree Collapse file tree
src/main/java/io/github/cotide/dapper/core/unit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -450,6 +450,13 @@ db.isDebug(true);
450450Database 指定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
Original file line number Diff line number Diff line change 66import io .github .cotide .dapper .basic .enums .IEnum ;
77import io .github .cotide .dapper .basic .enums .IntegerEnum ;
88import io .github .cotide .dapper .basic .enums .StringEnum ;
9+ import io .github .cotide .dapper .core .functions .TypeFunction ;
910import io .github .cotide .dapper .exceptions .SqlBuildException ;
11+ import io .github .cotide .dapper .query .Sql ;
1012import lombok .AccessLevel ;
1113import lombok .NoArgsConstructor ;
1214
2123public 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 {
You can’t perform that action at this time.
0 commit comments