spring-data-couchbase
spring-data-couchbase copied to clipboard
Add more default converters [DATACOUCH-234]
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
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
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)
#1057 adds a BigInteger Converter
Please open new issues for specific converters if needed. Many of the converters mentioned in this issue already exist.