Commit Graph

207 Commits

Author SHA1 Message Date
Mark Paluch
511ae51208 DATACASS-284 - Documentation. 2018-02-02 12:59:28 -08:00
John Blum
3a14cb411d DATACASS-485 - Polish documentation. 2018-02-01 23:07:01 -08:00
Mark Paluch
9fb3554f56 DATACASS-485 - Documentation. 2018-02-01 23:06:22 -08:00
Mark Paluch
f6f8da97ca DATACASS-515 - Updated changelog. 2018-01-24 13:41:19 +01:00
Mark Paluch
15fc3669aa DATACASS-514 - Updated changelog. 2018-01-24 12:22:06 +01:00
Mark Paluch
c0b9479599 DATACASS-512 - Support exists and count projections.
We now support exists and count projections derived from query methods and on Template API level.

Exists queries fetch rows limiting to a single row to optimize fetching.

Exists queries also support count results, i.e. a single row with a single numeric column is considered a count result. It's evaluated by comparing the number being greater to zero.

boolean exists = template.exists(Query.query(where("firstname").is("Walter")), Person.class);

long count = template.count(Query.query(where("lastname").is("White")), Person.class);

interface PersonRepository extends Repository<Person, String> {

    long countByLastname(String lastname); // derived query

    boolean existsByLastname(String lastname);  // derived query

    @CountQuery("SELECT COUNT(*) from users WHERE lastname = ?0")
    long countQueryByLastname(String lastname); // String-based query

    @ExistsQuery("SELECT * from users WHERE lastname = ?0 LIMIT 1")
    boolean existsQueryByLastname(String lastname);  // String-based query
}

Remove superfluous throws declarations.
2018-01-23 17:15:43 -08:00
Mark Paluch
4a592d9c0e DATACASS-516 - Polishing.
Apply fix also to reactive Cassandra example.

Original pull request: #117.
2018-01-15 11:14:47 +01:00
Dušan Andrić
f2fd2a1b8c DATACASS-516 - Add return type to sample code in reference docs.
Original pull request: #117.
2018-01-15 11:14:41 +01:00
Mark Paluch
7cd656bd94 DATACASS-508 - Updated changelog. 2017-11-27 16:43:41 +01:00
Mark Paluch
c2a19bf6c1 DATACASS-503 - Updated changelog. 2017-11-27 15:58:46 +01:00
Oliver Gierke
10c9c0c81d DATACASS-500 - Updated changelog. 2017-10-27 16:36:44 +02:00
Oliver Gierke
dbd5a0e701 DATACASS-491 - Updated changelog. 2017-10-11 19:01:36 +02:00
Mark Paluch
13440fcbfa DATACASS-492 - Prepare 2.0 GA (Kay). 2017-10-02 11:09:17 +02:00
Mark Paluch
f0f5304993 DATACASS-492 - Updated changelog. 2017-10-02 11:09:12 +02:00
Mark Paluch
243b81fd4f DATACASS-499 - Adapt to changed Spring Framework 5 documentation structure.
Update links in the reference docs to their new locations.
2017-09-27 14:00:09 +02:00
Mark Paluch
b4ded9168e DATACASS-493 - Update reference documentation for 2.0.
Update what's new and include migration guide.
2017-09-14 11:43:50 +02:00
John Blum
41457a40d1 DATACASS-489 - Polish. 2017-09-13 08:47:23 -07:00
Mark Paluch
4115cd3ca2 DATACASS-489 - Document SessionFactory in reference docs. 2017-09-13 08:41:14 -07:00
Mark Paluch
90bfa5317b DATACASS-56 - Cassandra paging support.
We now support forward-only paging with Cassandra through the Template API and Repositories. Results in Cassandra are paged by navigating forward-only through pages described by a binary paging state encapsulated by CassandraPageRequest and accessible via the returned Slice. Spring Data Page's do not fit to Cassandra's paging concept because Cassandra paging is not based on limit/offset.

Page requests are applicable to a Query and as parameter of query methods.

Query query = Query.empty().pageRequest(CassandraPageRequest.first(10));
Slice<User> slice = template.slice(query, User.class);

do {

    // consume slice

    if (slice.hasNext()) {
        slice = template.select(query, slice.nextPageable(), User.class);
    } else {
        break;
    }
} while (!slice.getContent().isEmpty());

assertThat(ids).hasSize(100);
assertThat(iterations).isEqualTo(10);

interface UserRepository implements Repository<User, String> {

    Slice<User> findAllByName(String name, Pageable pageRequest);
}
2017-09-11 23:22:43 -07:00
Mark Paluch
0ee5190f09 DATACASS-146 - Enhance Repository methods to accept QueryOptions as arguments.
We now support Repository query methods with query options. Query options can be passed either as an additional parameter to a Repository query method or applied with annotation.
Annotation-based query options are supported via @Consistency. A query options parameter has precedence over the annotation if a method declares both, an annotation-based consistency level and accepts a query options parameter.

interface SampleRepository extends Repository<Person, String> {

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

  @Consistency(ConsistencyLevel.LOCAL_ONE)
  Person findByAge(int age);

  Person findByAge(int age, QueryOptions options);
}

SampleRepository repository = …;

repository.findByAge(42, QueryOptions.builder().fetchSize(44).build());
2017-09-11 23:14:00 -07:00
John Blum
9fc7cd9eaa DATACASS-467 - Polish. 2017-09-11 16:30:18 -07:00
Mark Paluch
58e7bcc36d DATACASS-467 - Add migration guide describing upgrade paths from 1.5 to 2.0. 2017-09-11 16:29:21 -07:00
Mark Paluch
7e6556e3bd DATACASS-467 - Update documentation. 2017-09-11 16:29:06 -07:00
Oliver Gierke
8aa59ff4a2 DATACASS-480 - Prepare 2.0 RC3 (Kay). 2017-09-11 17:23:52 +02:00
Oliver Gierke
6dc6421076 DATACASS-480 - Updated changelog. 2017-09-11 17:23:44 +02:00
Mark Paluch
e53972880a DATACASS-481 - Updated changelog. 2017-09-11 12:43:51 +02:00
Mark Paluch
34af38b15f DATACASS-486 - Use unique property names in UDT reference documentation example. 2017-08-04 08:52:57 +02:00
Oliver Gierke
ad8eb9a989 DATACASS-477 - Updated changelog. 2017-07-27 00:48:52 +02:00
Oliver Gierke
9800c953e5 DATACASS-478 - Prepare 2.0 RC2 (Kay). 2017-07-25 15:33:32 +02:00
Oliver Gierke
115a930b4a DATACASS-478 - Updated changelog. 2017-07-25 15:33:20 +02:00
Oliver Gierke
ea70bdbf36 DATACASS-464 - Prepare 2.0 RC1 (Kay). 2017-07-25 09:48:01 +02:00
Oliver Gierke
1592e5cfc5 DATACASS-464 - Updated changelog. 2017-07-25 09:47:49 +02:00
Oliver Gierke
e65b026cb0 DATACASS-461 - Updated changelog. 2017-07-24 22:20:37 +02:00
Mark Paluch
9d3e12e3c4 DATACASS-306 - Create SASI indexes for annotated properties.
We now create SASI (SSTable Attached Secondary Index) indexes during session initialization for properties annotated with @SASI. Properties can be annotated with analyzer-annotations to configure analyzers.

@Table
public class Person {

		@Id String id;

		@SASI String names;

    @SASI @StandardAnalyzed(value = "de",
                enableStemming = true, normalization = Normalization.UPPERCASE,
                skipStopWords = true) String profession;

		@SASI @NonTokenizingAnalyzed String country;
}
2017-07-23 22:02:27 -07:00
Mark Paluch
4a0abd0f66 DATACASS-213 - Create secondary indexes for annotated properties.
We now create secondary indexes for annotated properties via @Indexed. Index creation is part of schema creation that is executed after Session initialization and table creation.

We support plain secondary indexes and key/value/entry indexes for map columns. Index creation is useful for rapid development but should not be used in large setups or at least with care to not impact performance in a negative way.

@Table
public class Person {

  @Id
  private String key;

  @Indexed("name_index")
  private String name;

  private Map<@Indexed String, String> keys;
}
2017-07-23 22:02:20 -07:00
Mark Paluch
1db32834e1 DATACASS-468 - Polishing.
Increase CassandraRepositoryConfigurationExtension visibility as this class is required by configuration infrastructure that configures Cassandra repository support such as Spring Boot.

Initialize MappingCassandraConverter with generic custom conversions and resolve package cycle between mapping and convert by initializing MappingCassandraConverter with generic custom conversions. Cassandra-specific custom conversions require external wiring via configuration.

Move IdInterfaceValidator to mapping package to resolve the final cycle between mapping and repository.support.
2017-07-18 13:31:43 +02:00
Mark Paluch
0ccb64a686 DATACASS-466 - Align insert(…) and update(…) return types to their possible outcomes.
We now return WriteResult for insert(…) and update(…) methods accepting WriteOptions. Conditional writes return a state whether the operation was applied or not and this result is propagated via WriteResult to the caller.

Synchronous insert(…) and update(…) without WriteOptions methods do not return a value and are consistent with other Template API modules. The absence of an Exception indicates success. Asynchronous and reactive insert(…) and update(…) without WriteOptions continue to return the entity to make the entity accessible after operation completion.

Previously, we returned null if a lightweight transaction was not applied or suppressed the value value emission.
2017-07-07 12:04:53 -07:00
Mark Paluch
d7e836b1e9 DATACASS-442 - Prepare 2.0 M4 (Kay). 2017-06-14 17:03:00 +02:00
Mark Paluch
253d1679d4 DATACASS-442 - Updated changelog. 2017-06-14 17:02:57 +02:00
Mark Paluch
8d64401aa8 DATACASS-250 - Support lightweight transactions.
We now support lightweight transactions via InsertOptions and UpdateOptions. Options can be used with the imperative, asynchronous and reactive templates using insert(…) and update(…) write methods. Write methods do not return the entity if the operation is not applied because of a lightweight transaction. Specifically, the resulting entity is null using the imperative and asynchronous Cassandra templates.

The reactive Cassandra template suppresses particular entities (inserted/updated through a entity stream) if its write operation was not applied due to a lightweight transaction.

InsertOptions lwtInsertOptions = InsertOptions.builder().withIfNotExists().build();

User user = new User("heisenberg", "Walter", "White");
User inserted = template.insert(user, lwtInsertOptions);

UpdateOptions lwtUpdateOptions = UpdateOptions.builder().withIfExists().build();

User user = new User("heisenberg", "Walter", "White");
User updated = template.update(user, lwtUpdateOptions);
2017-06-11 23:05:53 -07:00
Mark Paluch
dfe9c9d8a2 DATACASS-437 - Updated changelog. 2017-06-08 11:56:19 +02:00
Mark Paluch
870337d00a DATACASS-436 - Updated changelog. 2017-06-07 12:23:34 +02:00
Mark Paluch
caf4160604 DATACASS-452 - Align naming scheme for CassandraRepository.
We now follow a more consistent naming scheme for cassandra repository interfaces.

* The basic, store-specific interface is now named CassandraRepository
* An extended variant, using MapId's is named MapIdCassandraRepository

That results in the following renames:

* CassandraRepository -> MapIdCassandraRepository
* TypedIdCassandraRepository -> CassandraRepository

TypedIdCassandraRepository was re-introduced as deprecated variant now extending CassandraRepository to preserve a majority of existing repository declarations.
2017-06-01 11:43:32 +02:00
Mark Paluch
2b3f70ea92 DATACASS-448 - Relocate CQL, mapping and convert packages.
We relocated packages of the former Spring CQL module and mapping/convert packages of the Spring Data Cassandra module:

org.springframework.cassandra -> org.springframework.data.cql
org.springframework.cassandra.core.cql.generator -> org.springframework.data.cql.core.generator
org.springframework.cassandra.core.cql -> org.springframework.data.cql.core
org.springframework.data.cassandra.convert -> org.springframework.data.cassandra.core.convert
org.springframework.data.cassandra.mapping -> org.springframework.data.cassandra.core.mapping
2017-05-24 11:48:35 +02:00
Adam Holmberg
206999725a DATACASS-449 - Remove redundant paragraph in preface.
Original pull request: #104.
2017-05-24 10:28:34 +02:00
Mark Paluch
3e4016da42 DATACASS-343 - Provide reference documentation. 2017-05-15 16:16:15 -07:00
Mark Paluch
11777321b5 DATACASS-426 - Prepare 2.0 M3 (Kay). 2017-05-09 11:22:12 +02:00
Mark Paluch
f3dc41b040 DATACASS-426 - Updated changelog. 2017-05-09 11:22:03 +02:00
Mark Paluch
fee427e46c DATACASS-440 - Remove support for JodaTime's deprecated DateMidnight.
Related ticket: DATACMNS-1014.
2017-05-03 08:36:28 +02:00
Oliver Gierke
3991e2ef17 DATACASS-433 - Updated changelog. 2017-04-19 21:04:13 +02:00