当前位置:首页 > JAVA > 正文内容

springboot、MyBatis-Plus、hana数据库模型查询的处理

高老师2年前 (2023-01-04)JAVA494

hana数据库查询语句如下:

SELECT  *  FROM   "_SYS_BIC"."ellassay.public/AT_DIM_SAP_DEPOT_ALL_NEW_JTBB"  WHERE DEPOTID_JTBB ='S2351001'

想通过

@TableName(" \"_SYS_BIC\".\"ellassay.public/AT_DIM_SAP_DEPOT_ALL_NEW_JTBB\"")

进行查询,结果全部是null,于是通过自定xml进行查询

(1).创建xml

src/main/resources/mapper/AtDimSapDepotAllNewJtbb.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.learn.mapper.AtDimSapDepotAllNewJtbbMapper">
    <select id="getList" resultType="com.learn.entity.AtDimSapDepotAllNewJtbb">
        SELECT  *  FROM   "_SYS_BIC"."ellassay.public/AT_DIM_SAP_DEPOT_ALL_NEW_JTBB" 
    </select>
</mapper>

(2).创建实体

package com.learn.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

@TableName(" \"_SYS_BIC\".\"ellassay.public/AT_DIM_SAP_DEPOT_ALL_NEW_JTBB\"")
public class AtDimSapDepotAllNewJtbb {

    @TableField("PP")
    public String PP;


    public String getDEPOT_NAME() {
        return DEPOT_NAME;
    }

    public void setDEPOT_NAME(String DEPOT_NAME) {
        this.DEPOT_NAME = DEPOT_NAME;
    }

    @TableField("DEPOT_NAME")
    public String DEPOT_NAME;
}

(3).创建mapper

package com.learn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.learn.entity.AtDimSapDepotAllNewJtbb;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface AtDimSapDepotAllNewJtbbMapper extends BaseMapper<AtDimSapDepotAllNewJtbb> {
    List<AtDimSapDepotAllNewJtbb> getList();
}

(4).配置mybatis_pus

mybatis-plus:
  mapper-locations: classpath:mapper/*.xml
  configuration:
    map-underscore-to-camel-case: false

(5).进行查询

List<AtDimSapDepotAllNewJtbb>  monthTargetDepot1 =  atDimSapDepotAllNewJtbbMapper.getList();

其实是支持TableName转义字符串进行查询的,之所以查询的结果为null是因为没有关闭自动驼峰转换的原因, map-underscore-to-camel-case: false,这导致了 @TableField("nickname")注解失效了

扫描二维码推送至手机访问。

版权声明:本文由高久峰个人博客发布,如需转载请注明出处。

本文链接:https://blog.20230611.cn/post/420.html

分享给朋友:

“springboot、MyBatis-Plus、hana数据库模型查询的处理” 的相关文章

Java不用编译直接执行

Java不用编译直接执行

public class test {     public static void main(String[] args) {     &...

java stringBuffer,java stringBuffer反转字符串,java stringBuffer delete删除字符/移除字符,java stringBuffer在指定位置插入字符串,java stringBuffer替换指定位置的字符串,java stringBuffer获取指定索引的值

java stringBuffer,java stringBuffer反转字符串,java stringBuffer delete删除字符/移除字符,java stringBuffer在指定位置插入字符串,java stringBuffer替换指定位置的字符串,java stringBuffer获取指定索引的值

java stringBuffer(1).stringBuffer和stringBuilder区别stringBuffer是线程安全的,stringBuilder速度更快(2).简单的stringBuffer例子StringBuffer sBuffer = new&nb...

java睡眠方法,java睡眠函数,java睡眠时间,java睡眠一分钟,java睡眠五秒钟

java睡眠方法,java睡眠函数,java睡眠时间,java睡眠一分钟,java睡眠五秒钟

(1).java睡眠函数Thread.sleep(时间);  //单位为毫秒(2).java睡眠函数例子Date dNow = new Date(); SimpleDateFormat ft = new&nbs...

java获取时间戳,java时间戳获取

java获取时间戳,java时间戳获取

System.out.println("当前时间戳(秒): " + System.currentTimeMillis()/1000); System.out.println("当前时间戳(毫秒): " +&nb...

java正则表达式捕获组

java正则表达式捕获组

java正则表达式的捕获组捕获组可以将匹配到的结果根据正则中的括号进行分组,这里变量我加了$符,php转java的坏习惯,懒得改了,能跑就行// 匹配字符串 String $line = "gaojiufeng 1994! ok?...

java匹配一个字符串在另外一个字符串中出现的次数,java正则start,java正则end

java匹配一个字符串在另外一个字符串中出现的次数,java正则start,java正则end

java匹配一个字符串在另外一个字符串中出现的次数,java正则start,java正则end// 正则 String pattern = "\\bgao\\b"; // 字符串 String content ...