mybatis-plus使用达梦数据库处理枚举类型报错的问题

使用mybatis-plus连接达梦数据库,枚举类型无法读取

枚举类:
在这里插入图片描述

实体:
在这里插入图片描述
数据库字段:
在这里插入图片描述
mybatis-plus枚举包配置:
在这里插入图片描述
调用查询方法:

List<QualityRuleTemplate> qualityRuleTemplates = ruleTemplateService.list(new QueryWrapper<QualityRuleTemplate>().lambda()
.eq(QualityRuleTemplate::getRuleType, QualityRuleTypeEnum.DATASOURCE));

报错:

Caused by: dm.jdbc.driver.DMException: 不支持的接口或功能
	at dm.jdbc.driver.DBError.throwException(DBError.java:710) ~[DmJdbcDriver18-8.1.1.193.jar:- 8.1.1.193 - Production]
	at dm.jdbc.driver.DmdbResultSet.do_getObject(DmdbResultSet.java:1972) ~[DmJdbcDriver18-8.1.1.193.jar:- 8.1.1.193 - Production]
	at dm.jdbc.driver.DmdbResultSet.do_getObject(DmdbResultSet.java:1978) ~[DmJdbcDriver18-8.1.1.193.jar:- 8.1.1.193 - Production]
	at dm.jdbc.driver.DmdbResultSet.getObject(DmdbResultSet.java:5335) ~[DmJdbcDriver18-8.1.1.193.jar:- 8.1.1.193 - Production]
	at com.alibaba.druid.filter.FilterChainImpl.resultSet_getObject(FilterChainImpl.java:1395) ~[druid-1.2.18.jar:?]
	at com.alibaba.druid.filter.FilterAdapter.resultSet_getObject(FilterAdapter.java:1712) ~[druid-1.2.18.jar:?]
	at com.alibaba.druid.filter.FilterChainImpl.resultSet_getObject(FilterChainImpl.java:1391) ~[druid-1.2.18.jar:?]
	at com.alibaba.druid.filter.stat.StatFilter.resultSet_getObject(StatFilter.java:878) ~[druid-1.2.18.jar:?]
	at com.alibaba.druid.filter.FilterChainImpl.resultSet_getObject(FilterChainImpl.java:1391) ~[druid-1.2.18.jar:?]
	at com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl.getObject(ResultSetProxyImpl.java:1546) ~[druid-1.2.18.jar:?]
	at com.alibaba.druid.pool.DruidPooledResultSet.getObject(DruidPooledResultSet.java:1765) ~[druid-1.2.18.jar:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:69) ~[mybatis-3.5.7.jar:3.5.7]
	at com.sun.proxy.$Proxy489.getObject(Unknown Source) ~[?:?]
	at com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler.getNullableResult(MybatisEnumTypeHandler.java:118) ~[mybatis-plus-core-3.4.3.4.jar:3.4.3.4]
	at com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler.getNullableResult(MybatisEnumTypeHandler.java:49) ~[mybatis-plus-core-3.4.3.4.jar:3.4.3.4]
	at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:85) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyAutomaticMappings(DefaultResultSetHandler.java:561) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:403) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:355) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:329) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:302) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:195) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) ~[mybatis-3.5.7.jar:3.5.7]
	at jdk.internal.reflect.GeneratedMethodAccessor44.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64) ~[mybatis-3.5.7.jar:3.5.7]
	at com.sun.proxy.$Proxy486.query(Unknown Source) ~[?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor44.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64) ~[mybatis-3.5.7.jar:3.5.7]
	at com.sun.proxy.$Proxy486.query(Unknown Source) ~[?:?]
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.5.7.jar:3.5.7]
	at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:81) ~[mybatis-plus-extension-3.4.3.4.jar:3.4.3.4]
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) ~[mybatis-3.5.7.jar:3.5.7]
	at com.sun.proxy.$Proxy484.query(Unknown Source) ~[?:?]
	at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:81) ~[mybatis-plus-extension-3.4.3.4.jar:3.4.3.4]
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) ~[mybatis-3.5.7.jar:3.5.7]
	at com.sun.proxy.$Proxy484.query(Unknown Source) ~[?:?]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145) ~[mybatis-3.5.7.jar:3.5.7]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) ~[mybatis-3.5.7.jar:3.5.7]
	at jdk.internal.reflect.GeneratedMethodAccessor65.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ~[mybatis-spring-2.0.6.jar:2.0.6]
	at com.sun.proxy.$Proxy143.selectList(Unknown Source) ~[?:?]
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) ~[mybatis-spring-2.0.6.jar:2.0.6]
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166) ~[mybatis-plus-core-3.4.3.4.jar:3.4.3.4]
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77) ~[mybatis-plus-core-3.4.3.4.jar:3.4.3.4]
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.4.3.4.jar:3.4.3.4]
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.4.3.4.jar:3.4.3.4]
	at com.sun.proxy.$Proxy259.selectList(Unknown Source) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.27.jar:5.3.27]
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) ~[spring-tx-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:220) ~[spring-aop-5.3.27.jar:5.3.27]
	at com.sun.proxy.$Proxy260.selectList(Unknown Source) ~[?:?]
	at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:289) ~[mybatis-plus-extension-3.4.3.4.jar:3.4.3.4]
	at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke(<generated>) ~[mybatis-plus-extension-3.4.3.4.jar:3.4.3.4]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) ~[spring-aop-5.3.27.jar:5.3.27]
	at cn.ac.iscas.dmo.rest.service.quality.impl.QualityRuleTemplateServiceImpl$$EnhancerBySpringCGLIB$$171f9f98.list(<generated>) ~[main/:?]
	at cn.ac.iscas.dmo.rest.service.quality.impl.QualityRuleServiceImpl.getData(QualityRuleServiceImpl.java:72) ~[main/:?]
	at cn.ac.iscas.dmo.rest.service.quality.impl.QualityRuleServiceImpl$$FastClassBySpringCGLIB$$801bb2da.invoke(<generated>) ~[main/:?]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.27.jar:5.3.27]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) ~[spring-aop-5.3.27.jar:5.3.27]
	at cn.ac.iscas.dmo.rest.service.quality.impl.QualityRuleServiceImpl$$EnhancerBySpringCGLIB$$dd27b566.getData(<generated>) ~[main/:?]
	at cn.ac.iscas.dmo.rest.controller.quality.QualityRuleController.getDatasourceData(QualityRuleController.java:50) ~[main/:?]

查看mybatis-plus对枚举处理的handler:MybatisEnumTypeHandler

    @Override
    public E getNullableResult(ResultSet rs, String columnName) throws SQLException {
        Object value = rs.getObject(columnName, this.propertyType);
        if (null == value && rs.wasNull()) {
            return null;
        }
        return this.valueOf(value);
    }

调用了rs.getObject(columnName, this.propertyType)方法,此时this.propertyType是String
继续一直跟踪代码,发现最终调用了最终调用DmdbResultSet类中的方法:public Object do_getObject(int var1, Class var2)

    public Object do_getObject(int var1, Class var2) {
        DmdbTimestamp var3;
        if (var2 == LocalDateTime.class) {
            var3 = this.getTIMESTAMP(var1);
            return var3 == null ? null : LocalDateTime.of(var3.dt[0], var3.dt[1], var3.dt[2], var3.dt[3], var3.dt[4], var3.dt[5], var3.dt[6] * 1000);
        } else if (var2 == LocalDate.class) {
            var3 = this.getTIMESTAMP(var1);
            return var3 == null ? null : LocalDate.of(var3.dt[0], var3.dt[1], var3.dt[2]);
        } else if (var2 == LocalTime.class) {
            var3 = this.getTIMESTAMP(var1);
            return var3 == null ? null : LocalTime.of(var3.dt[3], var3.dt[4], var3.dt[5], var3.dt[6] * 1000);
        } else if (var2 == ZonedDateTime.class) {
            var3 = this.getTIMESTAMP(var1);
            return var3 == null ? null : ZonedDateTime.of(var3.dt[0], var3.dt[1], var3.dt[2], var3.dt[3], var3.dt[4], var3.dt[5], var3.dt[6] * 1000, ZoneOffset.ofTotalSeconds(var3.dt[7] != Integer.MIN_VALUE ? var3.dt[7] * 60 : this.connection.localTimezone * 60));
        } else if (var2 == OffsetDateTime.class) {
            var3 = this.getTIMESTAMP(var1);
            return var3 == null ? null : OffsetDateTime.of(var3.dt[0], var3.dt[1], var3.dt[2], var3.dt[3], var3.dt[4], var3.dt[5], var3.dt[6] * 1000, ZoneOffset.ofTotalSeconds(var3.dt[7] != Integer.MIN_VALUE ? var3.dt[7] * 60 : this.connection.localTimezone * 60));
        } else if (var2 == OffsetTime.class) {
            var3 = this.getTIMESTAMP(var1);
            return var3 == null ? null : OffsetTime.of(var3.dt[3], var3.dt[4], var3.dt[5], var3.dt[6] * 1000, ZoneOffset.ofTotalSeconds(var3.dt[7] != Integer.MIN_VALUE ? var3.dt[7] * 60 : this.connection.localTimezone * 60));
        } else {
            DBError.ECJDBC_UNSUPPORTED_INTERFACE.throwException(new String[0]);
            return null;
        }
    }

找到了问题所在,没有对String进行处理
这个类在达梦的驱动包里,我之前用的8.1.1.193,尝试更新版本为8.1.3.62
在这里插入图片描述

新的驱动中的处理

 public <T> T do_getObject(int columnIndex, Class<T> type) throws SQLException {
        if (type == String.class) {
            return this.do_getString(columnIndex);
        } else if (type == Clob.class) {
            return this.do_getClob(columnIndex);
        } else if (type == NClob.class) {
            return this.do_getNClob(columnIndex);
        } else if (type == Boolean.class) {
            return this.do_getBoolean(columnIndex);
        } else if (type == Long.class) {
            return this.do_getLong(columnIndex);
        } else if (type == Integer.class) {
            return this.do_getInt(columnIndex);
        } else if (type == Short.class) {
            return this.do_getShort(columnIndex);
        } else if (type == BigDecimal.class) {
            return this.do_getBigDecimal(columnIndex);
        } else if (type == Float.class) {
            return this.do_getFloat(columnIndex);
        } else if (type == Double.class) {
            return this.do_getDouble(columnIndex);
        } else if (type == Byte.class) {
            return this.do_getByte(columnIndex);
        } else if (type == byte[].class) {
            return this.do_getBytes(columnIndex);
        } else if (type == Blob.class) {
            return this.do_getBlob(columnIndex);
        } else if (type == Date.class) {
            return this.do_getDate(columnIndex);
        } else if (type == Time.class) {
            return this.do_getTime(columnIndex);
        } else if (type == Timestamp.class) {
            return this.do_getTimestamp(columnIndex);
        } else if (type == java.util.Date.class) {
            Timestamp t = this.do_getTimestamp(columnIndex);
            return t == null ? null : new java.util.Date(t.getTime());
        } else {
            DmdbTimestamp t;
            if (type == LocalDateTime.class) {
                t = this.getTIMESTAMP(columnIndex);
                return t == null ? null : LocalDateTime.of(t.dt[0], t.dt[1], t.dt[2], t.dt[3], t.dt[4], t.dt[5], t.dt[6]);
            } else if (type == LocalDate.class) {
                t = this.getTIMESTAMP(columnIndex);
                return t == null ? null : LocalDate.of(t.dt[0], t.dt[1], t.dt[2]);
            } else if (type == LocalTime.class) {
                t = this.getTIMESTAMP(columnIndex);
                return t == null ? null : LocalTime.of(t.dt[3], t.dt[4], t.dt[5], t.dt[6]);
            } else if (type == ZonedDateTime.class) {
                t = this.getTIMESTAMP(columnIndex);
                return t == null ? null : ZonedDateTime.of(t.dt[0], t.dt[1], t.dt[2], t.dt[3], t.dt[4], t.dt[5], t.dt[6], ZoneOffset.ofTotalSeconds(t.dt[7] != Integer.MIN_VALUE ? t.dt[7] * 60 : this.connection.localTimezone * 60));
            } else if (type == OffsetDateTime.class) {
                t = this.getTIMESTAMP(columnIndex);
                return t == null ? null : OffsetDateTime.of(t.dt[0], t.dt[1], t.dt[2], t.dt[3], t.dt[4], t.dt[5], t.dt[6], ZoneOffset.ofTotalSeconds(t.dt[7] != Integer.MIN_VALUE ? t.dt[7] * 60 : this.connection.localTimezone * 60));
            } else if (type == OffsetTime.class) {
                t = this.getTIMESTAMP(columnIndex);
                return t == null ? null : OffsetTime.of(t.dt[3], t.dt[4], t.dt[5], t.dt[6], ZoneOffset.ofTotalSeconds(t.dt[7] != Integer.MIN_VALUE ? t.dt[7] * 60 : this.connection.localTimezone * 60));
            } else if (type == Array.class) {
                return this.do_getArray(columnIndex);
            } else if (type == Struct.class) {
                return this.do_getStruct(columnIndex);
            } else if (type == Ref.class) {
                return this.do_getRef(columnIndex);
            } else if (type == SQLXML.class) {
                return this.do_getSQLXML(columnIndex);
            } else if (type == URL.class) {
                return this.do_getURL(columnIndex);
            } else if (type == RowId.class) {
                return this.do_getRowId(columnIndex);
            } else {
                DBError.ECJDBC_UNSUPPORTED_TYPE.throwz(new Object[0]);
                return null;
            }
        }
    }

问题至此解决了

  • 11
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
第1章结构化查询语言DM_SQL简介 ................................................................................................. 1 1.1 DM_SQL语言的特点 ................................................................................................................. 1 1.2 保留字与标识符 ........................................................................................................................ 2 1.3 DM_SQL语言的功能及语句 ..................................................................................................... 2 1.4 DM_SQL所支持的数据类型 ..................................................................................................... 3 1.4.1 常规数据类型 .................................................................................................................... 3 1.4.2 日期时间数据类型 ............................................................................................................ 6 1.4.3 多媒体数据类型 ................................................................................................................ 9 1.4.4 数据类型别名 .................................................................................................................... 9 1.5 DM_SQL语言支持的表达式 ..................................................................................................... 9 1.5.1 数值表达式 ...................................................................................................................... 10 1.5.2 字符串表达式 .................................................................................................................. 11 1.5.3 时间值表达式 .................................................................................................................. 12 1.5.4 时间间隔值表达式 .......................................................................................................... 13 1.5.5 运算符的优先级 .............................................................................................................. 14 1.6 DM_SQL语言支持的数据库模式 ........................................................................................... 15 第2章本手册中的实例说明 ............................................................................................................... 16 2.1 实例库说明 .............................................................................................................................. 16 2.2 参考脚本 ................................................................................................................................. 24 第3章数据定义语句 ........................................................................................................................... 42 3.1 数据库定义语句 ...................................................................................................................... 42 3.2 数据库修改语句 ...................................................................................................................... 44 3.3 数据库删除语句 ...................................................................................................................... 46 3.4 设置当前数据库语句 .............................................................................................................. 46 3.5 登录定义语句 .......................................................................................................................... 47 3.6 登录修改语句 .......................................................................................................................... 51 3.7 登录删除语句 .......................................................................................................................... 53 3.8 用户定义语句 .......................................................................................................................... 53 3.9 用户修改语句 .......................................................................................................................... 54 3.10 用户删除语句 ........................................................................................................................ 54 3.11 模式定义语句 ........................................................................................................................ 55 3.12 设置当前模式语句 ................................................................................................................ 56 3.13 模式删除语句 ........................................................................................................................ 57 3.14 基表定义语句 ........................................................................................................................ 57 3.15 基表修改语句 ........................................................................................................................ 68 3.16 基表删除语句 ..................................................................................................................... 74 3.17 全表删除语句 ........................................................................................................................ 75 3.18 索引定义语句 ........................................................................................................................ 76 3.19 索引删除语句 ........................................................................................................................ 78 3.20 序列定义语句 ........................................................................................................................ 79 3.21 序列删除语句 ........................................................................................................................ 80 3.22 全文索引定义语句 ................................................................................................................ 81 3.23 全文索引修改语句 ................................................................................................................ 81 3.24 全文索引删除语句 ................................................................................................................ 82 II 3.25 数据库快照定义语句 ............................................................................................................ 83 3.26 数据库快照删除语句 ............................................................................................................ 84 第4章数据查询语句和全文检索语句 ............................................................................................... 85 4.1 单表查询 ................................................................................................................................. 91 4.1.1 简单查询 .......................................................................................................................... 91 4.1.2 带条件查询 ...................................................................................................................... 92 4.1.3 集函数 .............................................................................................................................. 94 4.1.4 情况表达式 ...................................................................................................................... 96 4.2 连接查询 ................................................................................................................................. 98 4.3 子查询 ................................................................................................................................... 105 4.3.1 标量子查询 .................................................................................................................... 106 4.3.2 表子查询 ........................................................................................................................ 107 4.3.3 派生表子查询 ................................................................................................................ 109 4.3.4 定量比较 ........................................................................................................................ 110 4.3.5 带EXISTS谓词的子查询 ............................................................................................... 111 4.3.6 多列表子查询 ................................................................................................................ 112 4.4 查询结果的合并 .....................................................................................................................113 4.5 GROUP BY和HAVING子句 ...................................................................................................114 4.5.1 GROUP BY子句的使用 ................................................................................................. 114 4.5.2 HAVING子句的使用 ...................................................................................................... 115 4.6 ORDER BY子句 ......................................................................................................................116 4.7 选取前几条数据 .....................................................................................................................117 4.8 选取其中几条数据 .................................................................................................................117 4.9 全文检索 ................................................................................................................................118 4.10 层次查询 .............................................................................................................................. 120 4.10.1 层次查询子句 .............................................................................................................. 120 4.10.2 层次查询相关伪列 ...................................................................................................... 121 4.10.3 层次查询相关操作符 .................................................................................................. 121 4.10.4 层次查询相关函数 ...................................................................................................... 121 4.11 查看执行计划 ...................................................................................................................... 125 第5章数据的插入、删除和修改 ..................................................................................................... 126 5.1 数据插入语句 ........................................................................................................................ 126 5.2 数据修改语句 ........................................................................................................................ 129 5.3 数据删除语句 ........................................................................................................................ 130 5.4 伪列的使用 ............................................................................................................................ 131 5.4.1 ROWID ........................................................................................................................... 131 5.4.2 UID和USER .................................................................................................................... 132 5.4.3 ROWNUM ...................................................................................................................... 132 5.5 DM自增列的使用 ................................................................................................................... 132 5.5.1 DM自增列定义 ............................................................................................................... 132 5.5.2 SET IDENTITY_INSERT 属性 ..................................................................................... 133 第6章视图 ........................................................................................................................................ 136 6.1 视图的作用 .......................................................................................................................... 136 6.2 视图的定义 ............................................................................................................................ 137 6.3 视图的删除 ............................................................................................................................ 139 6.4 视图的查询 ............................................................................................................................ 140 III 6.5 视图数据的更新 .................................................................................................................... 141 第7章嵌入式SQL ............................................................................................................................. 143 7.1 SQL前缀和终结符 ................................................................................................................. 143 7.2 宿主变量 ............................................................................................................................... 143 7.2.1 输入和输出变量 ............................................................................................................ 144 7.2.2 指示符变量 .................................................................................................................... 145 7.3 服务器登录与退出 ................................................................................................................ 145 7.3.1 登录服务器 .................................................................................................................... 145 7.3.2 退出服务器 .................................................................................................................... 146 7.4 游标的定义与操纵 ................................................................................................................ 146 7.4.1 定义游标语句 ................................................................................................................ 147 7.4.2 打开游标语句 ................................................................................................................ 147 7.4.3 拨动游标语句 ................................................................................................................ 148 7.4.4 关闭游标语句 ................................................................................................................ 150 7.4.5 关于可更新游标 ............................................................................................................ 150 7.4.6 游标定位删除语句 ........................................................................................................ 150 7.4.7 游标定位修改语句 ........................................................................................................ 151 7.5 单元组查询语句 .................................................................................................................... 152 7.6 动态SQL ............................................................................................................................... 153 7.6.1 EXECUTE IMMEDIATE立即执行语句 ........................................................................ 154 7.6.2 PREPARE准备语句 ........................................................................................................ 155 7.6.3 EXCUTE执行语句 ......................................................................................................... 155 7.7 异常处理 ............................................................................................................................... 156 第8章函数 ........................................................................................................................................ 157 8.1 数值函数 ............................................................................................................................... 166 8.2 字符串函数 ............................................................................................................................ 173 8.3 日期时间函数 ........................................................................................................................ 184 8.4 空值判断函数 ........................................................................................................................ 193 8.5 类型转换函数 ........................................................................................................................ 194 8.6 杂类函数 ............................................................................................................................... 195 8.7 系统函数 ............................................................................................................................... 196 8.8 存储加密函数 ........................................................................................................................ 215 8.9 标记处理函数 ........................................................................................................................ 222 8.10 备份恢复函数 ...................................................................................................................... 223 8.11 附加分离数据库 .................................................................................................................. 230 第9章一致性和并发性 ..................................................................................................................... 233 9.1 DM事务相关语句 ................................................................................................................... 233 9.1.1 事务的开始 .................................................................................................................... 233 9.1.2 事务的结束 .................................................................................................................... 233 9.1.3 保存点相关语句 ............................................................................................................ 234 9.1.4 设置事务隔离级及读写特性 ........................................................................................ 235 9.2 DM手动上锁语句 ................................................................................................................... 236 第10章存储模块 ............................................................................................................................... 238 10.1 存储模块的定义 .................................................................................................................. 238 10.2 存储模块的删除 .................................................................................................................. 246 10.3 存储模块的控制语句 .......................................................................................................... 247 IV 10.3.1 语句块 .......................................................................................................................... 247 10.3.2 赋值语句 ...................................................................................................................... 249 10.3.3 条件语句 ...................................................................................................................... 249 10.3.4 循环语句 ...................................................................................................................... 250 10.3.5 EXIT语句 ...................................................................................................................... 252 10.3.6 调用语句 ...................................................................................................................... 253 10.3.7 RETURN语句 ............................................................................................................... 255 10.3.8 NULL语句 .................................................................................................................... 255 10.3.9 GOTO语句 .................................................................................................................... 255 10.3.10 RAISE语句 ................................................................................................................. 256 10.3.11 打印语句 .................................................................................................................... 256 10.4 存储模块的异常处理 .......................................................................................................... 256 10.4.1 异常变量的说明 .......................................................................................................... 257 10.4.2 异常的抛出 .................................................................................................................. 257 10.4.3 异常处理器 .................................................................................................................. 257 10.4.4 异常处理用法举例 ...................................................................................................... 257 10.5 存储模块的SQL语句 .......................................................................................................... 259 10.5.1 游标 .............................................................................................................................. 259 10.5.2 动态SQL ...................................................................................................................... 260 10.5.3 游标变量 ...................................................................................................................... 261 10.5.4 返回查询结果集 .......................................................................................................... 261 10.5.5 SQL语句应用举例 ........................................................................................................ 261 10.6 客户端存储模块 .................................................................................................................. 264 10.7 子过程、子函数 .................................................................................................................. 265 10.7.1 子过程 .......................................................................................................................... 265 10.7.2 子函数 .......................................................................................................................... 266 10.8 %TYPE、%ROWTYPE ....................................................................................................... 266 10.8.1 %TYPE .......................................................................................................................... 266 10.8.2 %ROWTYPE ................................................................................................................ 267 10.9 记录类型 .............................................................................................................................. 267 10.9.1 记录类型定义 .............................................................................................................. 267 10.9.2 记录赋值 ...................................................................................................................... 268 第11章触发器 .................................................................................................................................. 270 11.1 触发器的定义 ...................................................................................................................... 270 11.1.1 触发器类型 .................................................................................................................. 277 11.1.2 触发器激发顺序 .......................................................................................................... 279 11.1.3 新、旧行值的引用 ...................................................................................................... 280 11.1.4 触发器谓词 .................................................................................................................. 281 11.1.5 变异表 .......................................................................................................................... 282 11.1.6 设计触发器的原则 ...................................................................................................... 283 11.2 触发器的删除 ...................................................................................................................... 284 11.3 禁止和允许触发器 .............................................................................................................. 284 11.4 触发器应用举例 .................................................................................................................. 286 11.4.1 使用触发器实现审计功能 .......................................................................................... 286 11.4.2 使用触发器维护数据完整性 ...................................................................................... 286 11.4.3 使用触发器保障数据安全性 ...................................................................................... 287 V 11.4.4 使用触发器派生字段值 .............................................................................................. 288 第12章DM安全管理 ..................................................................................................................... 289 12.1 创建角色语句 ...................................................................................................................... 289 12.2 删除角色语句 ...................................................................................................................... 290 12.3 授权语句(数据库权限) ....................................................................................................... 290 12.4 授权语句(对象权限) ........................................................................................................... 291 12.5 授权语句(角色权限) ........................................................................................................... 295 12.6 回收权限语句(数据库权限) ............................................................................................... 295 12.7 回收权限语句(对象权限) ................................................................................................... 297 12.8 回收权限语句(角色权限) ................................................................................................... 299 12.9 策略与标记管理 .................................................................................................................. 300 12.9.1 创建策略 ...................................................................................................................... 300 12.9.2 修改策略 ...................................................................................................................... 300 12.9.3 删除策略 ...................................................................................................................... 302 12.9.4 安全标记 ...................................................................................................................... 302 12.9.5 用户标记设置语句 ...................................................................................................... 303 12.9.6 表标记设置语句 .......................................................................................................... 306 12.10 审计设置语句 .................................................................................................................... 308 12.11 审计取消语句 .................................................................................................................... 312 12.12 审计信息查阅语句 ............................................................................................................ 314 12.13 审计分析 ............................................................................................................................ 314 12.13.1 创建审计分析规则 .................................................................................................... 314 12.13.2 删除审计分析规则 .................................................................................................... 316 12.14加密引擎 ............................................................................................................................. 316 12.14.1 创建加密引擎 ............................................................................................................ 316 12.14.2 修改加密引擎 ............................................................................................................ 317 12.14.3 删除加密引擎 ............................................................................................................ 320 第13章外部链接 ............................................................................................................................... 321 13.1 创建外部链接 ...................................................................................................................... 321 13.2 删除外部链接 ...................................................................................................................... 322 13.3 使用外部连接进行远程对象操作 ...................................................................................... 322 第14章DM备份还原 ......................................................................................................................... 324 14.1 备份数据库 .......................................................................................................................... 324 14.2 还原数据库 .......................................................................................................................... 325 第15章包 ......................................................................................................................................... 327 15.1 创建包 ................................................................................................................................. 327 15.1.1 创建包规范 .................................................................................................................. 327 15.1.2 创建包主体 .................................................................................................................. 327 15.2 删除包 ................................................................................................................................. 328 15.2.1 删除包规范 .................................................................................................................. 328 15.2.2 删除包主体 .................................................................................................................. 329 15.3 应用实例 .............................................................................................................................. 329 第16章同义词 .................................................................................................................................. 332 16.1 创建同义词 .......................................................................................................................... 332 16.2 删除同义词 .......................................................................................................................... 332 附录1 关键字和保留字 ...................................................................................................................... 334 VI 附录2 SQL语法描述说明 ................................................................................................................... 338 附录3 SQL命令参考 ........................................................................................................................... 341 附录4系统存储过程和函数 ............................................................................................................... 343 附录5 DM技术支持 ............................................................................................................................ 387
### 回答1: MyBatis-Plus支持达梦数据库,可以通过下面的示例来实现对达梦数据库的适配:1. 在pom.xml文件中添加达梦数据库的驱动依赖: <dependency> <groupId>dm</groupId> <artifactId>dm-driver</artifactId> <version>7.7</version> </dependency>2. 在application.yml文件中配置达梦数据库的连接:spring: datasource: url: jdbc:dm://localhost:5236/test username: user password: 123456 driver-class-name: dm.jdbc.driver.DmDriver3. 在Mybatis-Plus的配置文件中添加对达梦数据库的自定义配置:mybatis-plus: configuration: dm: sql-injector: com.baomidou.mybatisplus.extension.injector.LogicSqlInjector4. 重新启动应用,MyBatis-Plus就可以正常使用达梦数据库了。 ### 回答2: MyBatis-Plus是一款优秀的持久层框架,它在MyBatis基础上进行了扩展和增强,提供了更为便捷的开发方式。 要适配达梦数据库,首先需要在项目的依赖管理中添加达梦数据库的驱动,可以通过Maven或Gradle下载并配置。 然后,在项目的配置文件中配置数据库连接信息,包括数据库类型、URL、用户名和密码等。 接下来,在项目中引入MyBatis-Plus的依赖,并配置相应的插件和拦截器,以支持MyBatis-Plus的特性和功能。可以使用@EnableMybatisPlus注解开启MyBatis-Plus的自动配置。 在编写数据访问层的代码时,可以使用MyBatis-Plus提供的通用Mapper接口和Wrapper查询构造器来实现便捷的数据库操作。通用Mapper接口提供了常见的增删改查方法,可以不再需要手动编写SQL语句,大大简化了开发工作。而Wrapper查询构造器提供了更为灵活的查询方式,可以进行复杂的条件查询。 此外,MyBatis-Plus还提供了代码生成器,可以根据数据库表结构自动生成实体类和Mapper接口的代码,极大地减少了手动创建的工作量。 综上所述,适配达梦数据库的示例主要包括添加数据库驱动、配置数据库连接信息、引入MyBatis-Plus依赖、配置插件和拦截器、使用通用Mapper接口和Wrapper查询构造器、以及使用代码生成器等步骤。通过这样的配置和操作,我们可以方便地使用MyBatis-Plus来操作达梦数据库,提高开发效率。 ### 回答3: MyBatis-Plus是一个在MyBatis基础之上进行扩展的数据库持久化框架,它提供了一系列的增强功能,简化了数据库操作的编写流程。但是,默认情况下,MyBatis-Plus并不支持达梦数据库,因为达梦数据库和其他主流数据库有一些不同之处。 要在MyBatis-Plus中适配达梦数据库,首先需要引入达梦数据库的相关的驱动包。可以下载达梦数据库官方提供的JDBC驱动包,并将其添加到项目的依赖中。 接着,在配置文件中,需要指定使用达梦数据库的数据库方言。可以通过设置 `mybatis-plus.global-config.db-config.db-type` 属性来指定数据库方言为`dm`。 然后,需要配置数据源,指定连接达梦数据库的相关信息,比如数据库的URL、用户名和密码等。可以通过在配置文件中配置数据源相关的属性来完成这一步骤。 接下来,可以使用MyBatis-Plus提供的各种操作方法来进行数据库的增删改查等操作。MyBatis-Plus中的操作方法和MyBatis中的类似,只是在一些语法和使用上有一些不同,需要根据达梦数据库的特点进行相应的调整。 最后,根据实际需求进行一些其他的配置和优化。比如,可以通过配置文件中的属性来设置一些缓存策略、分页方言等。 总之,适配达梦数据库主要包括引入相关的驱动包、配置数据源、设置数据库方言和使用MyBatis-Plus的操作方法等步骤。通过这些步骤的完成,就可以在MyBatis-Plus中成功适配达梦数据库,并进行相应的数据库操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值