We now support Session routing with AbstractRoutingSessionFactory. Session routing is based on a map, keyed by a lookup key that is supplied by an implementing class upon Session lookup.
Extend JavaConfig to configure a SessionFactory bean and configure CqlTemplate and CassandraAdminTemplate accordingly.
We now support SessionFactory to obtain Cassandra Session's on a per-request basis. CassandraAccessor is configured primarily with a SessionFactory now, the existing initialization configures a DefaultSessionFactory that returns the initially given Session instance.
Sessions should not be acquired directly by getSession but inside a callback-block so it's guaranteed to operate on the same session within a particular operation. That's especially relevant when preparing and executing prepared statements.
PreparedStatementCallback was changed in a breaking way as it now accepts additionally a Session to retain the session context.
Related ticket: DATACASS-32
Align declared type of CassandraCqlTemplateFactoryBean to CqlTemplate and the type of CassandraTemplateFactoryBean to CassandraTemplate to report consistent bean types. Add JavaDoc.
Original pull request: #76.
We now support multiple Cassandra keyspaces by allowing multiple definitions of Sessions, Mapping Contexts, Converters and CassandraTemplates.
Added support for id attribute for converter and mapping context elements and adopt CassandraMappingBeanFactoryPostProcessor to scan with eager initialization for existing infrastructure components. We are lenient about the source (factory bean or concrete bean definition) for infrastructure beans (Session, Converter, Mapping Context, Template) and register only the necessary beans.
Original pull request: #76.
Reuse Thread pools during integration test runs to not recreate and dispose Threads multiple times. Increase build and Cassandra memory. Use an external Cassandra instance for TravisCI build jobs.
We now drop Cassandra tables before dropping user types as user types cannot be removed when they are used in table definitions. Schema creation and schema drops are now split into two classes.
Reformat code. Add ticket references to test methods. Deprecate Comparator IT instances because of their unintuitive names and re-introduce it under INSTANCE.
We now compare persistent properties using their column names when both columns are regular columns. Column names either respect a defined column name or determine a column name based on the property name.
Previously, the comparison extracted the column name itself and in case the other column was not annotated, the column compared with itself, the column name with its own property name which breaks the comparator contract.
Improve documentation on CassandraTemplate. Explain differences between Spring CQL and Spring Data Cassandra. Add User-Defined-Type mapping example. Fix typos.
Align documentation structure with other Spring Data Modules. Add chapters for mapping and supported data types. Add new features chapter. Merge existing documentation into the aligned structure. Add John Blum and Mark Paluch to pom.xml.
We now support DTO projections for query methods. DTO projection selects records from Cassandra and applies projected results on the DTO. DTOs are plain Java objects that fit to the underlying entity.
@Table
class Person {
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0) private String lastname;
@PrimaryKeyColumn(type = PrimaryKeyType.CLUSTERED, ordinal = 1) private String firstname;
private String nickname;
private Date birthDate;
// more columns
}
interface PersonRepository extends CrudRepository<Person, String> {
Collection<PersonDto> findPersonDtoBy();
<T> T findDtoByFirstnameStartsWith(String prefix, Class<T> projectionType);
}
class PersonDto {
public String firstname, lastname;
public PersonDto(String firstname, String lastname) {
this.firstname = firstname;
this.lastname = lastname;
}
}
We no longer require entities to be annotated with @Table for data mapping and CRUD operations.
Entities without @Table can be still mapped in both directions and will be excluded from schema-management to prevent table creation for unwanted classes.
A class annotated with @Table will participate in schema management and be exposed as a table entity. Classes used as entities without @Table can still be used to query Cassandra but schema management will not create any tables for these classes.
@Table // entity qualified for schema management
class Person {
@Id private String id;
private String lastname;
private String firstname;
}
// entity that can be used for
// select/insert/update/delete operations and repository use
class Person {
@Id private String id;
private String lastname;
private String firstname;
}
Previously, query method parameter conversion was handled separately. This was duplicate code and the code additionally converted arguments into property types regardless the further usage. Collection arguments (e.g. for IN query usage) could be converted into the property type (List of String converted into String).
We now handle collection conversion and single element conversion separately so collections are no longer converted into the property's type. Collection elements are now inspected individually regarding their type/simple type conversion.
This change also considers enum types as simple types with a distinct conversion of the enum value into a Cassandra value (numeric, character). The change in enum value handling reduces the scope of the conversion service usage and prevents accidental conversion.
Original pull request: #89.
We now support @AliasFor to build composed annotations with @Table, @UserDefinedType, @PrimaryKey, @PrimaryKeyClass, @PrimaryKeyColumn, @Column, @Query, @CassandraType.
Original pull request: #90.
Revert added features in version 1.0 schema files in favor of version 1.5 schema files. Remove license header. Remove TODOs and fix documentation source names.