close

This Week in Spring - June 2, 2020

Hi, Spring fans. We’ve got a ton of stuff to cover this week so let’s get to it.

Read more

What's new in Spring Data Elasticsearch 4.0

This article continues our blog post series on What’s new in Spring Data Neumann. Today’s installment explains New and Noteworthy in Spring Data Elasticsearch. This blog post was written by P.J. Meisch who maintains the Spring Data Elasticsearch module.

This release addresses more than 140 issues, with more than 30 bugs fixed.

Spring Data Elasticsearch now uses Elasticsearch 7, 7.6.2 in particular. Elasticsearch clusters running on 6.x versions are not supported anymore. The ElasticsearchTemplate class is deprecated as it uses the TransportClient to access Elasticsearch, which itself is deprecated since Elasticsearch version 7.+ Users should switch to ElasticsearchRestTemplate or ReactiveElasticsearchTemplate.

Read more

This Week in Spring - May 26th, 2020

Hi, Spring fans! Welcome to another installment of This Week in Spring! How’re things? My family and I spent the Memorial Day holiday weekend mostly playing video games and trying random new restaurants for delivery. Now, it’s back to the grind and there are a ton of things to look at so let’s get to it!

Read more

Getting Started With RSocket: Testing Spring Boot Responders

Reading time: about 6 minutes
Coding time: about 15 minutes

If you’ve been following this series, by now, you’ll have built a Spring Boot prototype that illustrates many of the features present in RSocket. This code isn’t production code, though; it’s a prototype, a stepping stone on your RSocket journey. For production code, I’d expect all the usual quality assurance and testing rules to apply. So in this exercise, I’ll show you how to write integration tests for RSocket responders, so you can get one step closer to production.

Read more

Migrating to Spring Data JDBC 2.0

With Spring Data JDBC 2.0, we had to introduce some breaking changes. The goal of this article is to help in the migration process.

TL;DR

  1. Use the default letter casing for custom column and table names or quote the names for table generation exactly as used in the annotations.

  2. Use AbstractJdbcConfiguration for custom configuration of the application context.

  3. Register a Dialect if necessary.

  4. Review event-handling code and ensure the data you try to use is not null.

Quoting of Identifiers

Spring Data JDBC 1.x uses table and column names mostly without changing them. This causes problems when you use an SQL key word as a property or entity name or when you tried to use some special character in a column name.

For this reason Spring Data JDBC 2.0 quotes all identifiers by default. This makes the names case-sensitive, at least for most databases. Since we also, by default, convert the names generated into the default letter casing used by the database, this should not cause any problems, assuming you used no quotes in the CREATE TABLE statements, as most people do.

For example, consider a Student entity, as follows:

class Student {

    @Id
    Long id;
    String name;
}

A matching table for H2 could look like this:

CREATE TABLE STUDENT
(
    ID SERIAL PRIMARY KEY,
    NAME  VARCHAR(30)
);

That example is the same as in previous versions of Spring Data JDBC. Things change when you specify column or table names explicitly with @Column, @Table, or @MappedCollection. In this case, we assume that you specify the name exactly as you want it to be used and, therefore, the table definition has to use quoted identifiers or the names have to use the default letter casing of your database, as in this modified student example:

@Table("student")
class Student {

    @Id
    Long id;
    @Column("LAST_NAME")
    String name;
}

A matching table for H2 could look like this:

CREATE TABLE "student" -- (1)
(
    ID SERIAL PRIMARY KEY,
    LAST_NAME  VARCHAR(30) -- (2)
);
  1. The table name must be quoted, because it is given in lower-case letters but H2 converts unquoted SQL identifiers to upper case by default.

  2. LAST_NAME does not have to get quoted because it already uses the default letter casing.

See below how to disable the forced quoting if you really want to.

Read more

This Week in Spring - May 19th, 2020

Hi, Spring fans! Welcome to another installment of This Week in Spring! What a wonderful, bootiful week it’s been! This last week saw the long-awaited release of Spring Boot 2.3.0!

There are a lot of wonderful features in this release including, but not limited to, Java 14 support, Docker image generation, graceful shutdown, liveliness probes, upgrades to Spring Data Neumann, and so much more. Here are some resources on some of those features. And, also, check out the blog.

  • R2DBC support (see this Spring Tips installment on using R2DBC
  • Docker container image support. See this blog on Docker image generation
  • Java 14 support. See this Spring Tips installment on Java 14
  • This is also the version to use if you want to consume the Graal Native Image builder feature. Here’s a Spring Tips video on that, too.
Read more

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:

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