关于查询结果的数据结构(数据类型、长度、精度、非空等)
最后更新:2025-07-24 11:08:52
|
状态:未完成
通过service.query或querys查询返回的DataRow/DataSet中已经自动附带了来自数据库的数据结构
以下方法对于DataRow/DataSet同样适用
返回其中一列的数据结构
org.anyline.entity.data.Column getMetadata(String column)
Column中包含了数据类型、长度、精度、非空等结构数据
返回所有列的结构
LinkedHashMap<String, Column> getMetadatas()
返回一列的数据类型,如varchar
String getMetadataTypeName(String column)
返回一列的完整数据类型,如varchar(10)
String getMetadataFullType(String column)
返回对应的Java数据类型,如varchar对应的String
String getMetadataClassName(String column)
参考以下Column属性
protected String name ; // 名称
protected String originalName ; // 原名 SELECT ID AS USER_ID FROM USER; originalName=ID, name=USER_ID
protected String catalog ; // 数据库 catalog与schema 不同有数据库实现方式不一样
protected String schema ; // dbo mysql中相当于数据库名 查数据库列表 是用SHOW SCHEMAS 但JDBC con.getCatalog()返回数据库名 而con.getSchema()返回null
protected String className ; // 对应的Java数据类型 java.lang.Long
protected String tableName ; // 表名
protected Table table ; // 表
protected Integer displaySize ; // display size
protected String comment ; // 备注
protected Integer type ; // 类型
protected String typeName ; // 类型名称 varchar完整类型调用getFullType > varchar(10)
protected Integer precision ; // 整个字段的长度(包含小数部分) 123.45:precision = 5 ,scale = 2 对于SQL Server 中 varchar(max)设置成 -1
protected Integer scale ; // 小数部分的长度
protected int nullable = -1 ; // 是否可以为NULL -1:未配置 1:是 0:否
protected int caseSensitive = -1 ; // 是否区分大小写
protected int isCurrency = -1 ; // 是否是货币
protected int isSigned = -1 ; // 是否可以带正负号
protected int isAutoIncrement = -1 ; // 是否自增
protected Integer incrementSeed = 1 ; // 自增起始值
protected Integer incrementStep = 1 ; // 自增增量
protected int isPrimaryKey = -1 ; // 是否主键
protected int isGenerated = -1 ; // 是否generated
protected Object defaultValue ; // 默认值
protected String charset ; // 编码
protected String collate ; // 排序编码
protected Integer position ; // 在表或索引中的位置,如果需要在第一列 设置成0
protected String order ; // 在索引中的排序方式ASC | DESC
protected String after ; // 修改列时 在表中的位置
protected String before ; // 修改列时 在表中的位置
protected int isOnUpdate = -1 ; // 是否在更新行时 更新这一列数据