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

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

高老师3年前 (2023-01-04)JAVA639

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编译执行时编码问题

java编译编码问题,java编译执行时编码问题

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

java限制1个方法同一时间只能被一个线程访问

java限制1个方法同一时间只能被一个线程访问

java限制1个方法同一时间只能被一个线程访问public synchronized void setOrderPay(){ }加上synchronized 修饰符即可...

java增强型for循环

java增强型for循环

Java5 引入了一种主要用于数组的增强型 for 循环,类似js中的for inpublic class Member {     public static void main(String[]&...

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时间戳获取

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

java正则表达式判断字符串是否包含,java判断字符串是否包含

java正则表达式判断字符串是否包含,java判断字符串是否包含

pattern表示正则表达式,接收正则表达式作为参数例子:String content = "my name is gaojiufeng"; String pattern = "....