V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
abcdxx
V2EX  ›  Java

spring boot 使用 "Phoenix" JdbcTemplate 读取非主键字段的值结果为空

  •  
  •   abcdxx · 2018-11-09 19:20:34 +08:00 · 1602 次点击
    这是一个创建于 1988 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Phoenix 建表语句

    create table IF NOT EXISTS shop_day (
    face_id varchar not null,
    shop_key integer not null,
    date_key integer not null,
    business_key integer,
    brand_key integer,
    pv integer
    CONSTRAINT pk PRIMARY key (face_id, shop_key, date_key)
    );
    

    spring 配置

     spring   
        phoenix:
          datasource:
            url: jdbc:phoenix:127.0.0.1:2181
            driverclassname: org.apache.phoenix.jdbc.PhoenixDriver
            username:
            password:
    

    spring 代码

    
      @Qualifier("phoenixJdbcTemplate")
      @Autowired
      private JdbcTemplate jdbcPhoenix;
    
      void getFaceShopInfo() {
    
        String sql = "select * from shop_day where face_id in('1234')";
        Map<String, Object> stringObjectMap = jdbcPhoenix.queryForMap(sql);
      }  
    

    #stringObjectMap 只有 face_id, shop_key, date_key 主键字段有数据,其他字段数据都是 null

    在终端查询这条 sql 每个字段都有数据

    
    0: jdbc:phoenix:> select * from shop_day where face_id in('1234');
    

    有大佬知道是什么问题吗.

    4 条回复    2018-11-12 10:25:35 +08:00
    abcdxx
        1
    abcdxx  
    OP
       2018-11-09 20:13:16 +08:00
    ???
    szq8014
        2
    szq8014  
       2018-11-10 09:11:49 +08:00   ❤️ 1
    其他列是什么类型的?试试原生的 PreparedStatement/RestulSet ?
    再就是 in 查询一般返回多行为啥用 map 接,怎么也得上个 list 吧?
    thinkmore
        3
    thinkmore  
       2018-11-12 10:24:59 +08:00   ❤️ 1
    把你的 sql 语句拿到 phoenix client 中执行以下看看呢?或者在试一试指定返回字段看看
    thinkmore
        4
    thinkmore  
       2018-11-12 10:25:35 +08:00   ❤️ 1
    在确认下你 hbase 中表是否建好了,然后是不是有对应的列
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   952 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 19:49 · PVG 03:49 · LAX 12:49 · JFK 15:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.