Difference between codec and converters in Spring Data Cassandra?

pandiaraj

What's the main difference between Codec and Converters in Spring Data Cassandra?

mp911de

TL; DR;

TypeCodecs are part of DataStax's Java Cassandra driver. Converter's are Spring-specific to convert values on top of a driver.

TypeCodec

They are used to serialize/deserialize values using the Cassandra protocol:

A Codec that can serialize and deserialize to and from a given CQL type and a given Java Type.

Codecs are primarily used along with data types that map natively to Java types, such as INT to integer and VARCHAR to String.

A codec can also be used to map a UDT (represented as UDTValue) to a POJO using DataStax annotation-based Mapping add-on without requiring you to copy UDT values to POJO properties in your code.

Spring Data

Speaking of Spring Data for Apache Cassandra, it puts a layer of abstraction on top of the Cassandra driver. Spring Data handles object mapping and many more things that you don't get natively from the driver. Spring Data uses converters to convert a ResultSet Row to an object. Approaching conversion with conventions, you get a defaulted mapping behavior which does not require you to provide additional converters in the first place.

If you want to customize Spring Data's conversion, then you can provide a custom Converter to, e.g., convert JSON (stored as String) to an object or to store data types in Cassandra that would naturally not be serializable using Spring Data's default object mapping.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Conflict between spring-data-cassandra and spring-data-solr

Spring Data Cassandra codec not found for requested operation set<varchar> <-> java.util.Set

How to expose @EmbeddedId converters in Spring Data REST

Setup custom converters in Spring Data Mongo

Cassandra - What is difference between TTL at table and inserting data with TTL

What's the difference between dtype and converters in pandas.read_csv?

Difference between findBy and findOneBy in Spring data JPA

Spring Data JPA difference between findBy / findAllBy

Spring Data Slice: difference between getSize() and getNumberOfElements()

What is the difference between Hibernate and Spring Data JPA

Difference between Spring Data JPA and ORM

Spring Data REST - difference between @PrePersist and @HandleBeforeCreate?

Difference between the compression codec and file formats in hadoop?

Difference between blocking Spring Data and reactive Spring Data?

Spring data jpa for between search: difference Between or IsBetween?

Technical difference between Spring Boot with JOOQ and Spring Data JPA

Spring Data Cassandra and PreparedStatementCache

Does Spring Data JDBC support custom type converters

Difference between \*DATA and *DATA

What exactly is the difference between JpaRepository and CrudRepository using Spring Data JPA?

What's the difference between JPA and Spring Data JPA?

What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?

What's the difference between Spring Data's MongoTemplate and MongoRepository?

Spring Data MongoDB with text index: difference between matchingany and matchingphrase

What's the difference between Spring Data MongoDB and Hibernate OGM for MongoDB?

Spring ConversionService adding Converters

Spring message converters

Where's the difference between these two VLC codec identifiers?

Difference between BouncyCastle and Apache Commons Codec Base64 encoding