spring-data-couchbase icon indicating copy to clipboard operation
spring-data-couchbase copied to clipboard

Add more default converters [DATACOUCH-234]

Open spring-projects-issues opened this issue 9 years ago • 3 comments

Simon Baslé opened DATACOUCH-234 and commented

For instance, there is no BigInteger default converter, and serialization fails for these.

Take inspiration from MongoConvertershttps://github.com/spring-projects/spring-data-mongodb/blob/master/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverters.java#L72]?

See this stackoverflow question


Affects: 2.1.1 (Hopper SR1)

1 votes, 3 watchers

spring-projects-issues avatar Jun 07 '16 14:06 spring-projects-issues

Manish commented

Wouldn't it help to move this into the Spring Data Commons module so that all sub-modules can take advantage of the converters? After all, converting from String to BigInteger, BigDecimal, Currency, Locale, etc. and vice-versa is the same regardless of the underlying data store. The Converter interface in the Spring Data MongoDB project seems like a good candidate for moving into the Spring Data Commons project since it simply converts from one type to another

spring-projects-issues avatar Jun 08 '16 05:06 spring-projects-issues

Simon Baslé commented

Converter interfaces originate in commons (or even spring core) so that's covered (y)

About a generic commons set of converters, I think this hasn't been done because different stores have different capabilities, and some will be able to deal with certain types natively while others won't. JPA is capable of dealing natively with BigInteger for instance IIRC.

Also MongoDB will deal with java.util.Date but not the new Java 8 date types, so its default converters convert, eg. LocalDateTime to a Date, while Couchbase doesn't deal natively with dates at all, so its default converters will convert all sorts of dates to a String.

As you see, the common denominator between these converters is not that large, hence this proposed change (for now)

spring-projects-issues avatar Jun 08 '16 07:06 spring-projects-issues

#1057 adds a BigInteger Converter

mikereiche avatar Aug 25 '21 01:08 mikereiche

Please open new issues for specific converters if needed. Many of the converters mentioned in this issue already exist.

mikereiche avatar May 09 '23 23:05 mikereiche