ArangoDB - BigDecimal

时间:2018-01-26 21:02:13

标签: spring-boot arangodb

简单示例

@Data
@Document("product")
@Accessors(chain = true)
public class Product {
    @Id
    private String id;
    private BigDecimal cost;
}

ArangoDB配置:

@Override
public Builder arango() {
    final Builder builder = new Builder();
    arangoDbConfig.getHosts().forEach(host -> builder.host(host.getHost(), host.getPort()));
    return builder
            .user(arangoDbConfig.getUser())
            .password(arangoDbConfig.getPassword())
            .registerModule(new VPackJdk8Module());
}

阅读文档生成异常:

Invocation of init method failed; nested exception is org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate java.math.BigDecimal using constructor NO_CONSTRUCTOR with arguments 

相关性:

  1. SpingBoot 1.5.9
  2. Arangodb-spring-data 1.0.1
  3. Velocypack-module-jdk8 1.0.2
  4. 好的,请忘记将BigDecimal映射到HashMap。创建查询(greaterThan / lessThan)将是奇怪的。我将数据类型更改为Double。

1 个答案:

答案 0 :(得分:1)

您需要为包含BigDecimal的类定义JsonSerializer和JsonDeserializer,因为ArangoDB不支持该类型的数据。 查看此arango序列化程序文档:link