Commit Graph

128 Commits

Author SHA1 Message Date
Mark Paluch
cfa8a6177f 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:16:43 -08:00
Mark Paluch
84f680ee3e DATACASS-172 - Polishing.
Add tests. Add validations to Cql generators. Enhance JavaDoc. Create FieldSpecification for UDT fields.
2016-11-11 03:13:41 -08:00
Fabio Mendes
ac868d2f0a DATACASS-172 - Add CQL specifications/generators and UserDefinedType annotation. 2016-11-11 03:13:32 -08:00
Mark Paluch
3c80b2cb80 DATACASS-329 - Set up 2.0 development. 2016-10-25 09:37:49 +02:00
Mark Paluch
8ff1f0e3fc DATACASS-333 - Switch tests to AssertJ. 2016-10-25 09:37:13 +02:00
Mark Paluch
6b683f4346 DATACASS-350 - Add since version to existing deprecations. 2016-10-24 12:17:20 +02:00
Mark Paluch
24ffba5d2f DATACASS-276 - Use Row.getObject(…) instead of deserialization with CodecRegistry and ProtocolVersion.
We now rely on Row.getObject(…) to retrieve data from a Cassandra Column. CodecRegistry and ProtocolVersion are configured on Cluster so there's no need to use a static configured CodecRegistry and ProtocolVersion that might not fit the configured values.
2016-10-12 14:42:06 +02:00
Mark Paluch
54c7ab6928 DATACASS-335 - Reuse Cluster connection resources during tests where possible.
High client churn seems to affect Cassandra in a negative way (connection timeouts, driver considers hosts as down). Almost all integration tests bootstrap their own Cluster instance and dispose it once the tests has finished. Identify tests where reuse of a global Cluster instance provided by CassandraRule is possible and switch from context bootstrapping to reuse. This helps to prevent integration test failures.
2016-10-12 14:11:51 +02:00
Mark Paluch
add4cab01b DATACASS-347 - Support NettyOptions configuration in XML-based configuration.
We now support `NettyOptions` bean references in XML-based configuration.

<bean id="nettyOptions" class="…" />

<cass:cluster contact-points="…" netty-options-ref="nettyOptions" />
2016-10-12 14:11:50 +02:00
Mark Paluch
45d77ff73e DATACASS-344 - Polishing.
Switch heartbeatIntervalSeconds, idleTimeoutSeconds and poolTimeoutMilliseconds to primitive integers and compare values against defaults to decide whether to set these properties on PoolingOptions.
2016-10-12 14:11:50 +02:00
Mark Paluch
071c101c28 DATACASS-344 - Upgrade Cassandra Driver to 3.1.1.
We are now compatible with Datastax’ Cassandra Driver 3.1.1 and support the newly introduced configuration options MaxQueueSize for PoolingOptions.

This change also removes test assertions for PoolTimeoutMillis as this option was deprecated and made unusable with 3.1.1.
2016-10-12 14:11:47 +02:00
Mark Paluch
b07c708c7c DATACASS-346 - Upgrade embedded Cassandra to 3.9. 2016-10-12 12:25:45 +02:00
John Blum
f293516ecd DATACASS-217 - Polish.
Original pull request: #82.
2016-08-29 16:10:19 -07:00
Mark Paluch
23cb654b18 DATACASS-217 - Add support for LZ4 compression.
Original pull request: #82.
2016-08-29 16:10:11 -07:00
John Blum
c407aad8cf DATACASS-328 - Polish.
Original pull request: #81.
2016-08-09 14:59:39 -07:00
Mark Paluch
fd8e430592 DATACASS-328 - Revise QueryOptions and WriteOptions.
Deprecate our org.springframework.cassandra.core.ConsistencyLevel enum. Having an own consistency level type leads to confusion and it's always behind the driver. We don't want to maintain that type, so we decided to deprecate the own type and use the driver consistency levels.

We allow now the use of the driver retry policies aside of our consistency level enumeration. For most cases, our enumeration is the simpler approach. Some retry policies (IdempotenceAwareRetryPolicy, LoggingRetryPolicies) require further configuration and cannot be applied with just using a static enum value. We now support ReadTimeout, FetchSize, and Tracing via QueryOptions and WriteOptions and provide builders for QueryOptions and WriteOptions.

Original pull request: #81.
2016-08-09 14:59:28 -07:00
Mark Paluch
43ab34ac54 DATACASS-202 - Polishing.
Add author tags. Extend date range in headers. Simplify resolution by removing intermediate variables. Add test to verify ConsistencyLevel resolution. Guard consistency level against null.

Originall pull request: #54.
2016-07-28 15:27:17 +02:00
Antoine Toulme
da263df25c DATACASS-202 - Fix misspelled ConsistencyLevel enum constants.
Deprecate all misspelled consistency level enum values and add new consistency level enum values with correct spellings.

Original pull request: #54.
2016-07-28 15:26:25 +02:00
Oliver Gierke
229dbce133 DATACASS-269 - Prepare next development iteration. 2016-07-27 14:32:34 +02:00
Oliver Gierke
96d21eda0d DATACASS-269 - Release version 1.5 M1 (Ingalls). 2016-07-27 13:52:12 +02:00
Mark Paluch
7d5b79b9e4 DATACASS-238 - Polishing.
Reformat field declarations. Add/enhance JavaDoc. Add since tags to the new methods.

Original pull requests: #79, #80.
2016-07-26 12:14:01 +02:00
John Blum
58ed9789de DATACASS-325 - Add ClusterBuilderConfigurer configuration API.
We allow users to provide a ClusterBuilderConfigurer that can be applied to the Cluster Builder. ClusterBuilderConfigurer is a callback interface to handle extended configuration when the DataStax API changes. It allows configuration of options after all provided properties were set.

Original pull request: #79.
Related pull request: #80.
2016-07-26 12:04:35 +02:00
John Blum
dfc7e3a716 DATACASS-238 - Add Cluster configuration options.
We now support configuration of the cluster name, AddressTranslator, MaxSchemaAgreementWaitSeconds, SpeculativeExecutionPolicy and TimestampGenerator in the Cassandra Cluster factory. The cluster name is derived from the bean name, if not configured otherwise.

Related tickets: DATACASS-120, DATACASS-316, DATACASS-317, DATACASS-319, DATACASS-320.
Original pull request: #79.
Related pull request: #80.
2016-07-26 12:04:29 +02:00
Mark Paluch
1cc85fa68e DATACASS-305 - Polishing.
Add generics to list of specifications. Extract CQL generation in own method. Add author tag.

Original pull request: #70.
2016-07-05 09:34:33 +02:00
Stefan Birkner
5154d2b531 DATACASS-305 - Improve readability of CassandraCqlClusterFactoryBean.executeSpecsAndScripts.
We now check first whether any CQL statements need to be executed. This makes the code simpler because we don't have to check whether the session has already been created. Rename the Session variable system to session to omit confusion. Remove CQL logging here as CQL statements are logged inside the CqlTemplate.

Original pull request: #70.
2016-07-05 09:34:19 +02:00
John Blum
570d71a905 DATACASS-304 - CqlTemplate.doExecute does not translate Cassandra Exceptions. 2016-07-01 17:50:32 -07:00
John Blum
ab73021187 DATACASS-310 - Fix CqlTemplate and CassandraTemplate returning null for data access operations returning a Collection. 2016-07-01 17:26:04 -07:00
John Blum
931e777498 DATACASS-206, DATACASS-308 - Polish.
Original pull request: #73.
2016-07-01 14:35:54 -07:00
Mark Paluch
580adfb5c1 DATACASS-206 - Fix delete using custom column names.
We now use the specified column name from the entity annotation to construct the where clause in a delete statement.

Original pull request: #73.
2016-07-01 14:35:29 -07:00
Mark Paluch
66a69c0926 DATACASS-296 - Use CustomConversions for JSR-310, Joda and ThreeTen Backport types.
We now allow registering CustomConversions to register custom converters (read and write targets). CustomConversions registers by default JSR-310, Joda Time and ThreeTen backport type converters.
These types (LocalDate, LocalDateTime) can be used in domain classes and with query method arguments. Date-only types map to Cassandra's date type, Date and time types map to Cassandra's timestamp type. Type mapping works for singular and collection types (List and Set).

```
@Table
public Person

    @Id String id;

    java.time.LocalDate date;

    @CassandraType(type = Name.TIMESTAMP)
    java.time.LocalDate timestamp;

    List<org.threeten.bp.Instant> timestamps;
}
```

Original pull request: #68.
2016-06-29 19:21:08 -07:00
John Blum
fae1ba8591 DATACASS-192 - Polish.
Original pull request: #69.
2016-06-28 14:30:57 -07:00
Mark Paluch
f1e3ef48e8 DATACASS-192 - Support RENAME and DROP in ALTER TABLE specification.
Extend alter table specification and the linked CQL generator to support RENAME and DROP operations. Cleanup code in that area.

Original pull request: #69.
2016-06-28 14:30:50 -07:00
Mark Paluch
38fef212e4 DATACASS-192 - Fix syntax error when adding columns using CQL generators.
The Add-Column CQL generator now generates correct CQL statements.

Original pull request: #69.
2016-06-28 14:30:40 -07:00
John Blum
f30468627d DATACASS-298 - Fix DATACASS-176 issue reference hyperlink. 2016-06-20 14:09:08 -07:00
John Blum
2958d13923 DATACASS-242 - Fix shutdown script issue with XML Configuration.
The XML Configuration now handles configured shutdown scripts correctly.

Original pull request: #67.
2016-06-20 09:37:06 +02:00
Mark Paluch
56c46f9460 DATACASS-298 - Polishing.
Extends date range in license headers. Apply formatting rules. Create BeanDefinitionTestUtils and simplify tests. Add ticket references.

Original pull request: #66.
2016-06-20 09:15:47 +02:00
John Blum
3d9835d99a DATACASS-298 - Add missing PoolingOptions to the XML namespace as well as the PoolingOptionsFactoryBean.
Original pull request: #66.
2016-06-20 09:15:33 +02:00
John Blum
97be7d6fc3 DATACASS-297 - Polish.
Original pull request: #65.
2016-06-14 15:57:55 -07:00
Mark Paluch
1b4eec9dd4 DATACASS-297 - Add support for streaming queries to select entities.
We now support java.util.stream.Stream as return type on query methods. Streaming queries wrap the iterator returned by Cassandra's ResultSet. Elements are fetched in batches (see QueryOptions that can be set in CassandraCqlClusterFactoryBean) and processed element by element instead of reading all results. Streaming queries are supported only for select queries.

Original pull request: #65.
2016-06-14 15:57:47 -07:00
John Blum
f6aef61d51 DATACASS-287 - Polish.
Original pull request: #63.
2016-06-03 14:44:21 -07:00
Mark Paluch
76f3d32360 DATACASS-287 - Polishing.
Move test listeners into a common support package. Hide constructors and introduce factory methods. Encapsulate fields. Add volatile modifier to fields to prevent visibility issues. Enhance JavaDoc on CassandraOperations.
2016-06-03 14:44:11 -07:00
Mark Paluch
b14956cb67 DATACASS-287 - Call QueryForObjectListener for absent singular responses.
QueryForObjectListener is now called passing null for absent responses when querying for one single object.
2016-06-03 14:43:51 -07:00
John Blum
165064084a DATACASS-253 - Polish.
Original pull request: #62.
2016-06-03 12:29:50 -07:00
Mark Paluch
39dca76e7c DATACASS-253 - Add synchronization to CachedPreparedStatementCreator.
CachedPreparedStatementCreator is now thread-safe and synchronizes concurrent calls to statement preparation. The synchronization prevents multiple calls to Session.prepare(…) for the same session, CQL statement and keyspace.
2016-06-03 12:25:01 -07:00
Mark Paluch
abcac5f5ee DATACASS-263 - Fix authentication configuration in CassandraCqlClusterFactoryBean.
Configuring username/password authentication does no longer require setting of an AuthProvider which would be overwritten by the username/password authenticator.
2016-06-03 10:08:23 +02:00
Mark Paluch
1d1ba3d998 DATACASS-286 - Polishing.
Update years in license headers where needed. Apply Spring Data formatting to method blocks. Add issue reference to tests. Remove trailing whitespaces. Remove throws declarations in CqlTemplate for runtime exceptions. Add author tags. Adjust JavaDoc about not null parameters. Align not null assertion messages with Spring Data wording.

Original pull request: #61.
2016-05-30 10:24:43 +02:00
John Blum
39928948f0 DATACASS-286 - Log all CQL queries executed with CqlTemplate.
Additional refactoring to simplify CqlTemplate logic as well as make CqlTemplate methods more behaviorally consistent.

Origina pull request: #61.
2016-05-30 10:24:32 +02:00
Mark Paluch
be495728d9 DATACASS-271 - Polishing.
Add author tags. Add/update license headers where needed. Remove calls to deprecated methods. Adopt pooling options after the driver update. Add hints_directory for Cassandra 3.

Reduce driver baseline to core driver 3.0.1. The DSE driver requires the core driver itself and can be added as dependency to user projects while retaining full compatibility. As of now the DSE driver is rc1 hence it requires core rc1.

Use getTimestamp for timestamp type methods as the driver aligned the method to the type. Support short, byte and time. Enable LocalDate return type and add tests for native supported types.

Change long to bigint type as long was mapped to the counter type when creating tables. Align the default to bigint as bigint is the better choice since table creation uses mostly regular tables and not counter tables. Type can be overriden using @CassandraType.

We now support setting NettyOptions on CassandraCqlClusterFactoryBean and AbstractClusterConfiguration. The cassandra driver 2.1.9 changed its default shutdown behavior by introducing a 2 second quiet period when shutting down Cluster instances. This change was retained throughout the 3.0 driver which slow the test down by an order of magnitude. Configure QueryOptions on tests to prevent delays caused by the asynchronous schema refresh.

Original pull request: #56.
Related pull request: #52.
Related ticket: DATACASS-169.
2016-05-20 12:54:19 -07:00
Antoine Toulme
a920b530df DATACASS-271 - Upgrade to Cassandra 3.0.
This commit adds support for Cassandra 3.x with upgrading to Datastax Driver 3.0.0. Data type deserialization is performed using the CodecRegistry.

Original pull request: #52.
Related ticket: DATACASS-169.
2016-05-20 12:54:11 -07:00
John Blum
27019f3218 DATACASS-219 - Polish.
Refactored code based on @Mark Paluch's code review here (https://github.com/spring-projects/spring-data-cassandra/pull/55).
2016-05-11 11:51:12 -07:00