spring-projects / spring-data-cassandra

Provides support to increase developer productivity in Java when using Apache Cassandra. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-cassandra/
Apache License 2.0
376 stars 309 forks source link

Add support for TupleType/TupleValue [DATACASS-284] #455

Closed spring-projects-issues closed 6 years ago

spring-projects-issues commented 8 years ago

Mark Paluch opened DATACASS-284 and commented

Cassandra provides a TupleType which allows storing multiple values within one column/field as tuple. A tuple type is defined by a list of data types and does not require any further setup on Cassandra beyond the table definition. UDT's require, in comparison to tuple types, an additional type definition.

@Table
public class MyEntity {

    @CassandraType(type = Name.TUPLE,
            typeArguments = { Name.VARCHAR, Name.INT })
    private TupleValue tupleValue;
}

Issue Links:

Referenced from: pull request https://github.com/spring-projects/spring-data-cassandra/pull/120

spring-projects-issues commented 6 years ago

Mark Paluch commented

Spring Framework and Spring Data have no tuple types. Cassandra has and it would be nice to support mapped tuples in some way.

Following Tuple2<T1, T2> and so on is less context than say having a Point type. A possible approach to mapped tuples could be:

@Tuple
class Point {

  @Element(0) double x;
  @Element(1) double y;
}

Tuples are cheaper to declare than user-defined types

spring-projects-issues commented 6 years ago

John Blum commented

PR #120 reviewed, polished and merged to master for the Spring Data (Cassandra) Lovelace M1 release