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")注解失效了