close

Christoph Strobl

Christoph Strobl

Spring Data Committer

Pregarten, Austria

Blog Posts by Christoph Strobl

What's new in Spring Data (Klara Dan von) Neumann?

Spring Data Neumann is the first release to follow the new six-month cadence. The reduced timeframe lets us deliver new features more often, which is key in enabling you to move faster. The release itself ships with a bunch of new stuff and includes important (potentially breaking) upgrades of several store.

Major Version Upgrades

Several store modules, as listed below, required a major version bump due to potentially breaking changes in either their exposed API or their drivers:

  • Spring Data JDBC 2.0 (was 1.1 before)

  • Spring Data MongoDB 3.0 (was 2.2 before)

  • Spring Data for Apache Cassandra 3.0 (was 2.2 before)

  • Spring Data Couchbase 4.0 (was 3.2 before)

  • Spring Data Elasticsearch 4.0 (was 3.2 before)

Before moving on to selected new features let’s break down some those API changes. If in doubt, please visit the Upgrading sections of the modules reference documentation. And, for those worried because the upgrade would be too painful right now, the previous Moore release train will still be around and will receive updates for another twelve months.

JDBC Every SQL store comes with its very own specialties that required specific treatment. To better support this, a couple of changes had to be made, resulting a major version bump for the module. Now, by default, the AbstractJdbcConfiguration will try to determine the database specific Dialect from the provided DataSource or registered DialectResolver. Out of the box, the JDBC modules ships with dialects for H2, HSQLDB, MySQL, Postgres, MariaDB, Microsoft SqlServer and DB2. Spring Data JDBC now also by default quotes all table names and columns. While this might force you to adapt either your CREATE TABLE statements or your @Column annotations it gives greater flexibility when choosing those names.

MongoDB Spring Data MongoDB picks up the MongoDB Java and reactive streams 4.0 driver generation that lets you choose the desired methodology without having to have the other on the path. Therefore, both the sync as well as the reactive MongoDB driver are now optional dependencies that need to be added manually. With the new drivers, some of the already deprecated API has finally been removed, impacting exposed configuration classes like AbstractMongoConfiguration and XML namespace elements provided by the Spring Data implementation. We summarized public facing changes in the Upgrading Section of the reference documentation.

Apache Cassandra The long overdue upgrade to the Apache Cassandra 4.0 driver generation, with not only its new package and data structure but also changed behavior in cluster and session handling, leads to extensive changes in configuration that will bleed into user configuration when using the XML namespace or more complex scenarios than just the default setup with AbstractCassandraConfiguration.

Couchbase The Couchbase module follows the Couchbase SDK and upgrades from Version 3.x to 4.x which includes automatic index management and transaction support. Read the full story in their Blog.

Elasticsearch The release adds support for the HTTP Client API, SSL, and Proxy support, along with extensive internal changes that included streamlining and removing of (deprecated) API, which required a major version bump. The Elasticsearch module now ships a Document covering Get-, Index- and Search-Requests allowing the mapping layer to use types like SearchHit, SearchHits and SearchPage.

Having the stage set, let’s move on to a selection of new features.

Read more...

Spring Data for Apache Solr Discontinued

Dear Spring Data Community,

We want to share news with you about the Spring Data for Apache Solr module.
After its initial rise as one for the first community-led Spring Data projects and its later inception as one of the core modules, community interest, feature requests, and bug reports have declined.

In our effort to balance time (based on popularity and usage data of the projects we have) the module has seen only occasional updates and fixes for the past few years. This is why we are seeking volunteers who are willing to help maintain the module, putting Spring Data for Apache Solr back into community mode.

Read more...

What's new in Spring Data Moore?

Spring Data Moore ships with 16 modules and over 700 tickets completed. It includes tons of improvements and new features across the portfolio and has a strong focus on three major topics: Reactive, Kotlin, and Performance. The release adds features such as declarative reactive transactions and Coroutines/Flow support and comes with up to 60%* faster finder methods.

Let’s start with a look at some of the Reactive features of Moore.

Declarative, reactive transactions

The Lovelace Release introduced early support for reactive transactions in a closure-fashioned style that left some room for improvements. The following listing shows that style:

Reactive Transactions in Lovelace (with MongoDB)
public Mono<Process> doSomething(Long id) {

  return template.inTransaction().execute(txTemplate -> {

    return txTemplate.findById(id)
      .flatMap(it -> start(txTemplate, it))
      .flatMap(it -> verify(it))
      .flatMap(it -> finish(txTemplate, it));

  }).next();
}

In the preceding snippet, the transaction has to be initiated by explicitly calling inTransaction() with a transaction-aware template within the closure, calling next() at the end to turn the returned Flux into a Mono to satisfy the method signature, even though findById(…) already emits only a single element.

Obviously, this is not the most intuitive way of doing reactive transactions. So let’s have a look at the same flow using declarative reactive transaction support. As with Spring’s transaction support, you need a component to handle the transaction for you. For reactive transactions, a ReactiveTransactionManager is currently provided by the MongoDB and R2DBC modules. The following listing shows such a component:

@EnableTransactionManagement
class Config extends AbstractReactiveMongoConfiguration {

  // …

  @Bean
  ReactiveTransactionManager mgr(ReactiveMongoDatabaseFactory f) {
    return new ReactiveMongoTransactionManager(f);
  }
}

From there, you can annotate methods with @Transactional and rely on the infrastructure to start, commit, and roll back transactional flows to handle the lifecycle via the Reactor Context. This lets you turn the code from Lovelace into the following listing, removing the need for the closure with its scoped template and the superfluous Flux to Mono transformation:

Declarative Reactive Transactions in Moore (with MongoDB)
@Transactional
public Mono<Process> doSomething(Long id) {

  return template.findById(id)
    .flatMap(it -> start(template, it))
    .flatMap(it -> verify(it))
    .flatMap(it -> finish(template, it));
}
Read more...

Spring Data Moore RC1 and Lovelace SR9 released

On behalf of the team I am pleased to announce Spring Data releases Moore RC1 and Lovelace SR9. The new bits build on the most recent Spring Framework releases and will be picked up by Spring Boot 2.2 M4 and 2.1.6 respectively.

Notable new features amongst others are:

  • An EntityCallback API for modifying entities before convert or save.
  • Multiple OUT parameters in the stored procedure support of Spring Data JPA.
  • Declarative aggregations in Spring Data MongoDB.
  • Enhanced SSL support and dynamic client port configuration for Gemfire and Apache Geode.
Read more...

Spring Data Moore M3 released

Hot on the heels of Spring Framework 5.2 M1 and just in time for the upcoming Spring Boot 2.2 M2 release, on behalf of the Spring Data team, I’m pleased to announce the availability of the third milestone of the Moore release train.

Notable changes amongst many others:

  • Flow extensions for Kotlin coroutines in Spring Data for Apache Cassandra & MongoDB.
  • MongoDB Json Schema generation from domain Types.
  • Support for BINARY storage type in Spring Data JDBC.
  • Alternative EntityMapper for Elasticsearch.
  • Improved Geospatial query support for Neo4j.
  • Smarter Redis cluster topology caching.
Read more...

Spring Data Moore M2 released

On behalf of the Spring Data team, I’m pleased to announce the availability of the second milestone of the Moore release train.

Notable changes include:

  • Support for Kotlin Coroutines in Spring Data MongoDB, Cassandra and Redis.
  • Querydsl support for reactive repositories.
  • Range type support for derived repository query methods using between for Spring Data MongoDB & Cassandra.
  • exists projection in Neo4j repositories.
  • Reactive repositories for Spring Data Elasticsearch.
  • Pivotal Gemfire and Apache Geode upgrades.
  • Upgrade to Spring HATEOAS 1.0 M1.
  • …and numerous features for the JDBC module like direct insert & update methods skipping the is new check.
Read more...

Spring Data Moore M1 released

On behalf of the Spring Data team, I’m pleased to announce the availability of the first milestone of the Moore release train.

Notable changes include:

Read more...

What's new in Spring Data Lovelace for MongoDB?

The past year has seen a lot of enhancements brought to the NoSQL Store including a bunch of new features and extended capabilities. We collaborated closely with the driver team at MongoDB, so the release already ships with decent support for sessions, change streams, schema validation, and (of course) transactions.

The most interesting new feature is probably MongoDB 4.0’s support for Multi-Document Transactions. If you have followed this blog before, you have probably read our Hands on Guide that explains both ClientSessions (which are the main building block) and transactions themselves. In short, SpringData provides you with everything you need to leverage Spring managed transaction support in your project. To use it, declare MongoTransactionManager in your configuration, as the following example shows:

Read more...

Hands on MongoDB 4.0 transactions with Spring Data

With MongoDB 4.0, ACID transactions have arrived in the Document store, enforcing all-or-nothing execution and maintaining data integrity. So, let’s get straight to it by looking at both the synchronous and the reactive execution models.

At the time of this writing, MongoDB multi-document transactions are supported across a single replica set and feel like the transactions you are probably familiar with from relational databases. Looking at the driver API, one feels immediately at home:

try (ClientSession session = client.startSession()) {

    session.startTransaction();

    try {

        collection.insertOne(session, documentOne);
        collection.insertOne(session, documentTwo);

        session.commitTransaction();

    } catch (Exception e) {
        session.abortTransaction();
    }
}
Read more...

Spring Data Lovelace M3 released

On behalf of the Spring Data team, I’m pleased to announce the availability of the third milestone of the Lovelace release train.

This release ships with updates for all store modules that contain new features, improvements, and bug fixes. Notable changes include:

Read more...