Skip to content

Allow users to opt into storing BigInteger as Decimal128 [DATAMONGO-2590] #3444

Closed
@spring-projects-issues

Description

@spring-projects-issues

Christoph Strobl opened DATAMONGO-2590 and commented


Issue Links:

  • DATACMNS-1615 Allow fine grained store specific converter registration
    ("depends on")
  • DATAMONGO-1517 Add support for Decimal128 BSON type

1 votes, 3 watchers

Activity

spring-projects-issues

spring-projects-issues commented on Jul 16, 2020

@spring-projects-issues
Author

Jeff Yemin commented

BigDecimal is probably the more common type that users would want to map to Decimal128

christophstrobl

christophstrobl commented on Jan 20, 2021

@christophstrobl
Member

BigDecimal to Decimal128 conversion is possible by using the @Field annotation as shown below.

@Field(targetType = FieldType.DECIMAL128)
BigDecimal bigDecimal;

By registering a custom BigInteger -> Decimal128 converter it is possible to apply the above also to BigInteger properties.

enum BigIntegerToDecimal128Converter implements Converter<BigInteger, Decimal128> {
	INSTANCE;

	public Decimal128 convert(BigInteger source) {
		return ...
	}
}

// ...

@Field(targetType = FieldType.DECIMAL128)
BigInteger bigInteger;
mp911de

mp911de commented on Jan 20, 2021

@mp911de
Member

Should we consider defaulting to Decimal128 for Spring Data 3.0 with a config setting to revert to String?

Mcfloy

Mcfloy commented on Mar 6, 2025

@Mcfloy

Should we consider defaulting to Decimal128 for Spring Data 3.0 with a config setting to revert to String?

Sorry to necrobump 4 years later, I 100% agree with @mp911de on defaulting to Decimal128 instead of String as we would be able to use expressions on numbers like $lt, $lte, $gt, $gte that we cannot do "easily" with String as it would require the usage of $toDecimal (in an aggregation).

We missed the 3.0 milestone, but can we try to push this modification for the next version* ?

added this to the 4.5 M2 (2025.0.0) milestone on Mar 11, 2025

3 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Allow users to opt into storing BigInteger as Decimal128 [DATAMONGO-2590] · Issue #3444 · spring-projects/spring-data-mongodb