Commit Graph

750 Commits

Author SHA1 Message Date
Mark Paluch
49436f867f DATACASS-386 - Update project documentation with the CLA tool integration. 2017-01-13 11:30:36 +01:00
Mark Paluch
17312ea085 DATACASS-385 - Migrate ticket references in test code to Spring Framework style. 2017-01-11 12:06:39 +01:00
Mark Paluch
15a30f7493 DATACASS-355 - Polishing.
Extend JavaDoc. Add ticket reference to test method. Reorder methods. Add leading line to multi-statement methods.
2017-01-06 11:19:29 +01:00
Mark Paluch
74943ca754 DATACASS-355 - Drop tables before dropping user types.
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.
2017-01-06 11:03:18 +01:00
Mark Paluch
62f522d23a DATACASS-380 - Polishing.
Guard tests against incompatible Cassandra versions.
2017-01-03 16:23:00 +01:00
Mark Paluch
066740f004 DATACASS-380 - Upgrade to Cassandra Driver 3.1.2. 2017-01-03 16:03:08 +01:00
Mark Paluch
31d3022054 DATACASS-352 - Polishing.
Reformat code. Add ticket references to test methods. Deprecate Comparator IT instances because of their unintuitive names and re-introduce it under INSTANCE.
2017-01-03 11:34:03 +01:00
Mark Paluch
f6e9869951 DATACASS-352 - Compare persistent properties using column names in CassandraPersistentPropertyComparator.
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.
2017-01-03 11:33:44 +01:00
Mark Paluch
75f07c43f2 DATACASS-379 - Add package documentation. 2017-01-03 09:18:44 +01:00
Oliver Gierke
f1a98f54b4 DATACASS-327 - After release cleanups. 2016-12-21 16:33:12 +01:00
Oliver Gierke
d2d5fd5eef DATACASS-327 - Prepare next development iteration. 2016-12-21 16:33:09 +01:00
Oliver Gierke
beb38a955e DATACASS-327 - Release version 1.5 RC1 (Ingalls). 2016-12-21 16:16:50 +01:00
Oliver Gierke
cd5a65e908 DATACASS-327 - Prepare 1.5 RC1 (Ingalls). 2016-12-21 16:15:47 +01:00
Oliver Gierke
5900995486 DATACASS-327 - Updated changelog. 2016-12-21 16:15:35 +01:00
Mark Paluch
76bc50db9d DATACASS-370 - Use newer Java 8 on Travis CI. 2016-12-16 10:58:28 +01:00
Oliver Gierke
0a6bf87f83 DATACASS-369 - Adapt API in CassandraRepositoryFactoryBean.
Related tickets: DATACMNS-891.
2016-12-15 15:07:56 +01:00
John Blum
079cd699cc DATACASS-272 - Polish. 2016-12-14 00:22:45 -08:00
Mark Paluch
3e1b79d74b DATACASS-272 - Revise readme.
Reflect requirements. Consolidate configuration bits. Align with other Spring Data readme files.
2016-12-14 00:22:45 -08:00
Mark Paluch
dd8750d32c DATACASS-272 - Explain primary key handling. 2016-12-14 00:22:45 -08:00
Mark Paluch
a995ea5ee6 DATACASS-272 - Consistently use Spring Data for Apache Cassandra. 2016-12-14 00:22:45 -08:00
Mark Paluch
60d3b307e5 DATACASS-360 - Document schema management. 2016-12-14 00:22:45 -08:00
Mark Paluch
88f57b75ce DATACASS-272 - Add composed annotations to what's new section. 2016-12-14 00:22:45 -08:00
Mark Paluch
f0eed347ff DATACASS-272 - Extend documentation.
Improve documentation on CassandraTemplate. Explain differences between Spring CQL and Spring Data Cassandra. Add User-Defined-Type mapping example. Fix typos.
2016-12-14 00:22:45 -08:00
Mark Paluch
f759f070ef DATACASS-272 - Add mapping/converter configuration and repository support to documentation. 2016-12-14 00:22:45 -08:00
Mark Paluch
a2d74d8535 DATACASS-272 - Enhance the SD Cassandra Reference Guide.
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.
2016-12-14 00:22:45 -08:00
John Blum
cc9ec8333f DATACASS-272 - Review and edit the SD Cassandra Reference Guide. 2016-12-14 00:22:44 -08:00
Mark Paluch
67c549dd76 DATACASS-364 - Register CassandraRepositoryFactory in spring.factories.
This is required for the switch in support for multi-store detection.

Related ticket: DATACMNS-952.
2016-12-05 16:10:47 +01:00
Mark Paluch
8b053661e3 DATACASS-363 - Add import order config file.
Delete also attic directory since it's not required anymore.
2016-11-30 09:21:20 +01:00
John Blum
0a49981b9d DATACASS-360 - Polish. 2016-11-29 13:58:37 -08:00
Mark Paluch
9591e1f4fc DATACASS-359 - Support DTO projections.
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;
  }
}
2016-11-29 13:57:54 -08:00
Mark Paluch
8543846dea DATACASS-360 - Do not require @Table annotation.
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;
}
2016-11-29 13:56:15 -08:00
John Blum
21e3ee3795 DATACASS-357 - Polish. 2016-11-28 17:33:05 -08:00
Mark Paluch
b0ba2c7664 DATACASS-357 - Move parameter conversion to MappingCassandraConverter.
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.
2016-11-28 17:32:58 -08:00
John Blum
041af2d0fc DATACASS-259 - Polish. 2016-11-28 16:10:44 -08:00
Mark Paluch
1818d23330 DATACASS-259 - Allow usage of Spring 4.2 @AliasFor for Cassandra annotations.
We now support @AliasFor to build composed annotations with @Table, @UserDefinedType, @PrimaryKey, @PrimaryKeyClass, @PrimaryKeyColumn, @Column, @Query, @CassandraType.

Original pull request: #90.
2016-11-28 16:10:37 -08:00
Mark Paluch
e4190bcdfa DATACASS-351 - Revert Spring Data Cassandra 1.5 changes in 1.0 schema files.
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.
2016-11-28 15:29:34 +01:00
John Blum
c3584e6883 DATACASS-172 - Polish. 2016-11-11 03:10:06 -08:00
Mark Paluch
2195374c68 DATACASS-172 - Support for UDTs.
We now support Cassandra User-defined types. UDTs can be created using CQL generators and used inside of mapped domain classes. User-defined types can be used either raw as UDTValue that is passed through or as mapped object. Mapped UDTs must be annotated with @UserDefinedType. Types are included into schema generation so known and defined UDTs are created before any tables are created. UDTs can be used with set and list collection types and in primary keys. UDTs can also be used in repository query methods as query predicates.
Updating UDTs will update the whole UDT.

@UserDefinedType
public class Address {
  String city;
  String country;
}

@Table
public class Person {

  @Id String id;
  Address address;
  UDTValue genericUdt;
}

The XML namespace support was extended with new schema versions to support provide a User Type resolver so UDTs can be resolved:

<cassandra:mapping>
  <cassandra:user-type-resolver keyspace-name="${cassandra.keyspace}" />
</cassandra:mapping>
2016-11-11 03:08:57 -08:00
Mark Paluch
a36e7beecb DATACASS-172 - Polishing.
Add tests. Add validations to Cql generators. Enhance JavaDoc. Create FieldSpecification for UDT fields.
2016-11-11 03:08:43 -08:00
Fabio Mendes
1865c31708 DATACASS-172 - Add CQL specifications/generators and UserDefinedType annotation. 2016-11-11 03:08:30 -08:00
Oliver Gierke
0c1f958c9d DATACASS-342 - Updated changelog. 2016-11-03 18:56:41 +01:00
Mark Paluch
8ff1f0e3fc DATACASS-333 - Switch tests to AssertJ. 2016-10-25 09:37:13 +02:00
Mark Paluch
fcd383ef15 DATACASS-349 - Consider custom write converters for collection types.
We now consider registered custom write converters for top-level collection types (like Map<String, Collection<String>>) to convert properties to Java types. Previously, only collection component types and non-collection top-level types were used to determine a converter.
2016-10-24 15:03:32 +02:00
Mark Paluch
6b683f4346 DATACASS-350 - Add since version to existing deprecations. 2016-10-24 12:17:20 +02:00
Mark Paluch
b7bdd4cd7c DATACASS-350 - Deprecate CassandraTemplate methods accepting collections of entities.
Methods accepting a List of entities perform batching operations (insert/update/delete).
This can be fine for entities sharing a partition key but leads in most cases to distributed batches across a Cassandra cluster which is an anti-pattern. CassandraTemplate exposes CassandraBatchOperations for batching operations. As of Version 1.5, all methods accepting a List of entities are deprecated because there is no alternative of inserting multiple rows in an atomic way that guarantees not to harm Cassandra performance. These methods will be removed in Version 2.0.
2016-10-24 12:17:20 +02:00
John Blum
aee38017ba DATACASS-117 - Polish. 2016-10-18 22:21:01 -07:00
Mark Paluch
1bc460ca0a DATACASS-117 - Support named and expression parameters in String-based repository query methods.
We now support named and expression parameters in String-based repository query methods. Name-based parameters are referenced with :parameter. Expression parameters can reference either parameter names (if provided) with :#{expression}/#{#fieldname} or index-based with ?#{[0]}.

String-based query creation now also serializes parameters using the configured CodecRegistry so escaping and serialization is handled by the driver itself which leads to correct queries.

public interface SampleRepository extends Repository<Person, String> {

  @Query("SELECT * FROM person WHERE lastname = ?0;")
  Person findByLastname(String lastname);

  @Query("SELECT * FROM person WHERE lastname = :lastname;")
  Person findByNamedParameter(@Param("lastname") String lastname);

  @Query("SELECT * FROM person WHERE lastname = ?#{[0]};")
  Person findByIndexExpressionParameter(String lastname);

  @Query("SELECT * FROM person WHERE lastnames IN (?0) AND age = ?1;")
  Person findByLastNamesAndAge(Collection<String> lastname, int age);

  @Query("SELECT * FROM person WHERE lastname = :#{#lastname == 'Matthews' ? 'Admin' : #lastname};")
  Person findByConditionalExpressionParameter(@Param("lastname") String lastname);
}

Related tickets: DATACASS-122, DATACASS-240
2016-10-18 22:20:55 -07:00
John Blum
fac4323372 DATACASS-258 - Polish. 2016-10-17 22:09:07 -07:00
Mark Paluch
c3700eede3 DATACASS-258 - Split metadata verifier for Entities and PrimaryKey types.
We provide now two separate verifiers for Table types and PrimaryKey types. Exception messages are aligned between both verifiers and the checks use simplified code instead to perform checks. VerifierMappingExceptions introduces now immutability and methods introducing mutability are deprecated.
2016-10-17 22:08:59 -07:00
Mark Paluch
8c39fa4787 DATACASS-276 - Polishing.
Truncate table while it contains data to reach a defined state for testing.
2016-10-12 14:42:11 +02:00