You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java访问Azure Table Storage:无法获取PK/RK外的实体属性值

解决Azure表存储无法获取自定义属性值的问题

问题根源

你的ImportantData实体类存在两个关键问题:

  • 自行定义了PartitionKey和RowKey字段,而父类TableServiceEntity已经内置这两个属性,重复定义会导致SDK序列化/反序列化逻辑冲突。
  • 自定义字段AssociatedData1使用默认包访问权限,不符合Azure表存储SDK的JavaBean序列化要求,SDK无法正确识别并赋值。

修正后的实体类

移除重复主键字段,将自定义字段改为私有,并通过父类构造方法初始化主键:

public class ImportantData extends TableServiceEntity {
    private String AssociatedData1;

    public ImportantData(String partitionKey, String rowKey, String associatedData1) {
        super(partitionKey, rowKey);
        this.AssociatedData1 = associatedData1;
    }

    public ImportantData() {
        super();
    }

    public String getAssociatedData1() {
        return AssociatedData1;
    }

    public void setAssociatedData1(String associatedData1) {
        AssociatedData1 = associatedData1;
    }
}

特殊场景处理

如果Azure表中的属性名和实体类字段名存在大小写差异,可通过@Property注解明确映射:

@Property(name = "associatedData1")
private String AssociatedData1;

验证效果

修改实体类后重新执行查询代码,控制台将输出预期结果:

true
MMBI | 12345678

内容的提问来源于stack exchange,提问作者Jrdan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 16:35:22