tarantool / cartridge-springdata

Spring Data Tarantool
Other
18 stars 7 forks source link

Methods for custom mapping setup #111

Open bitgorbovsky opened 2 years ago

bitgorbovsky commented 2 years ago

There is no functionality for setting custom mappings on springdata level. It would be nice to have such possibility, for example, I want to map some flat structure (e.g tuple, and perhaps, nested tuples) with some classes (it's usually called unflattening).

akudiyar commented 1 year ago

The built-in extension points for Spring Data converters (Java type to Java type) are available, look: https://github.com/tarantool/cartridge-springdata/blob/master/src/main/java/org/springframework/data/tarantool/config/AbstractTarantoolDataConfiguration.java#L211. Probably we are lacking a test for it and a link to the Spring Data doc about that in our README.

As for the MessagePack to Java type conversions, the users are supposed to use the TarantoolConfig: https://github.com/tarantool/cartridge-springdata/blob/master/src/main/java/org/springframework/data/tarantool/config/AbstractTarantoolDataConfiguration.java#L93 and https://github.com/tarantool/cartridge-java/blob/master/src/main/java/io/tarantool/driver/api/TarantoolClientConfig.java#L353 - they are supposed to provide a custom MessagePackMapper instance with their custom converters. Probably we need to update the driver version in the module and add the relevant section in the README.

Is that what you had in mind or something else?