3Qn
3Qn

Reputation: 139

ArangoDB - BigDecimal

Simple example

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

ArangoDB configuration:

@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());
}

Reading document generate exception:

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 

Dependency:

  1. SpingBoot 1.5.9
  2. Arangodb-spring-data 1.0.1
  3. Velocypack-module-jdk8 1.0.2

Ok, just forget BigDecimal is mapped to HashMap. Creating queries (biggerThan/lessThan) will be bizarre. I change the data type to Double.

Upvotes: 1

Views: 204

Answers (1)

Buben Ivanov
Buben Ivanov

Reputation: 157

You need to define JsonSerializer and JsonDeserializer for class which contains BigDecimal, because ArangoDB do not have support for that type of data. Check this arango serializer documentation: link

Upvotes: 1

Related Questions