首页 > 其他分享 >Mybatisplus TableInfoHelper:获取entity对应的数据表字段列表

Mybatisplus TableInfoHelper:获取entity对应的数据表字段列表

时间:2024-10-23 19:43:46浏览次数:1  
标签:tableInfo Mybatisplus openid TableInfoHelper entity field baomidou

如题,调用 TableInfoHelper#getTableInfo(clazz) 这个工具方法可以得到entity类所对应的数据表的字段列表。

import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfo;


    TableInfo tableInfo = TableInfoHelper.getTableInfo(ScbgPayOrder.class);

    // 输出字段列表
    if (tableInfo != null) {
        List<TableFieldInfo> fieldList = tableInfo.getFieldList();
        for (TableFieldInfo field : fieldList) {
            System.out.println("Field Name: " + field.getProperty());
        }
    } else {
        System.out.println("Table not found");
    }

 

代码中的ScbgPayOrder类有如下field。

 

注意到 openid有 @TableField(exist = false) 声明,这表示 openid 不是数据表字段。则输出的结果里不会包含openid。

标签:tableInfo,Mybatisplus,openid,TableInfoHelper,entity,field,baomidou
From: https://www.cnblogs.com/buguge/p/18498177

相关文章

  • spring mybatis upgrade to mybatisplus 实战小记
    我司压箱底儿的灵工服务商系统,系统框架是spring,持久层是mybatis。最近,将Mybatisplus集成到系统中,以提高开发效率。升级版本:mybatis版本3.2.2,升级到3.5.16Mybatisplus版本:3.5.3mybatis-spring版本1.2.0,升级到3.0.0pagehelper版本:5.3.1【注】mybatis官方提供了Myba......
  • MyBatisPlus
    一,MybatisPlus基础1.1要使用mybatisPlus需要的两个步骤;1.引入MybatisPlus的依赖点击查看代码<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.3.1</version></depe......
  • Duende.IdentityServer
    服务端安装install-package Duende.IdentityServer客户端install-package IdentityModelwebapi 基于jwt需要安装install-package Microsoft.AspNetCore.Authentication.JwtBearer 在IdentityServer中启用OIDC需要交互式用户界面 dotnetnewisuiOIDC范围的配......
  • The instance of entity type 'xxx' cannot be tracked because another instance wit
    发生的原因,在CheckProductionCode()方法中根据主键id查询对象时没有使用AsNoTracking(),示例:_db.Productions.AsNoTracking()那么EF会把查询出的对象缓存并跟踪对象状态,之后再Update的时候就会查询现有已跟踪的对象,发现已经存在一个相同主键的对象,所以报错。///<summary>///......
  • 【Azure Developer】com.azure:azure-identity jar包版本从1.2.0 升级到1.12.2 版本之
    问题描述com.azure:azure-identityjar包版本从1.2.0升级到1.12.2版本之后报错,错误信息如下:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:  com.azure.identity.implementation.IdentityClientBase.getConf......
  • 【Azure Developer】com.azure:azure-identity jar包版本从1.2.0 升级到1.12.2 版本之
    问题描述com.azure:azure-identityjar包版本从1.2.0升级到1.12.2版本之后报错,错误信息如下:Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation:  com.azure.identity.implementation.IdentityClientBase.get......
  • Entity Framework Core 中使用仓库和工作单元事务,服务层和控制器
    定义实体首先定义一个实体,例如Product:publicclassProduct{publicintId{get;set;}publicstringName{get;set;}publicdecimalPrice{get;set;}}CopyInsert2.创建DbContext创建一个DbContext类:publicclassAppDbContext:DbContext{public......
  • 使用Entity Framework Core(EF Core)进行开发时,结合仓库模式和工作单元模式,服务层以及控
    仓储(Repository)仓储模式封装对数据源的访问逻辑,包括CRUD操作。以下是一个简单的仓储接口和实现示例:publicinterfaceIRepositorywhereT:class{Task<IEnumerable>GetAllAsync();TaskGetByIdAsync(intid);TaskAddAsync(Tentity);TaskUpdateAsync(Tentity);Tas......
  • 实体-关系图(Entity-Relationship Diagram)【er图步骤】【数据库设计步骤】
    1.第一步:根据宠物商店业务逻辑建立petstoreE-R图2.第二步:将petstoreE-R图转换为关系模式3.第三步:将petstore数据库规范化第一范式:保证每一列的原子性,每个属性只能包含单一值,不能是重复的或多值的(ok)第二范式:每一个非主键字段都是依赖于主键字段的(违者,如商品分类拆出来......
  • CloseableHttpResponse当程序进入 catch 块的情况下,就不得不在catch 中获取entity,这
    如果程序进入catch块时还需要获取responseentity,但此时try-with-resources会自动关闭资源,导致无法再从response中获取数据,这种情况下,你可以避免在try-with-resources中立即关闭CloseableHttpResponse,并延迟处理资源的关闭。为了解决这个问题,下面是几种可行的方式:1.......