Skip to content

Spring Data 2023.0 (Ullman) Release Notes

Christoph Strobl edited this page Mar 16, 2023 · 29 revisions

General Themes

  • AOT reflection Hints for Querydsl Q classes

  • Add support for Kotlin Inline classes

  • Add keyset-based pagination for MongoDB and JPA modules

Participating Modules

Details

New and Noteworthy

Spring Data Commons - 3.1

Spring Data JPA - 3.1

Spring Data JPA introduces HQL and JPQL parser!

One of Spring Data JPA’s handy features is letting users plugin in custom JPA queries through its @Query annotation. This isn’t too rigid, because developers are still able to apply Sort parameters giving end-users the ability to plugin various sort critiera. On top of that, Spring Data JPA supports paging, which requires the ability to count result sets.

interface SampleRepository extends CrudRepository<Employee, Long> {

    @Query("select e from Employee e where e.firstName = ?1")
    List<Employee> findCustomEmployees(String firstName, Sort sort);

}

Thus we have allowed supported users by taking their @Query-provided queries and applied additional order by clauses and count() operations to support these mode of operations. Unfortunately, that support has been tricky the more complex custom queries become since for a long time, we only had a regular expression utility to support that.

The query above with a Sort.by("lastName") would turn into:

select e
from Employee e
where e.firstName = ?1
order by e.lastName

With https://github.com/spring-projects/spring-data-jpa/issues/2814, we have introduced a parser both for HQL (Hibernate Query Language) as well as spec-defined JPQL (JPA Query Language). Now, anytime you write a query, it is run through a proper parser, and it become much easier to curate the "final" query users need, whether that involves adding additional sort criteria to a query that already has an order by clause, or adding a new one should none exist.

We can also proper put the count() found in the right place to support Pageable queries that have a custom query.

What’s especially nice is that you don’t have to do anything. Spring Data JPA can detect whether or not Hibernate is on the classpath and switch between HQL or plain old JPQL.

Spring Data Relational - 3.1

Spring Data MongoDB - 4.1

Explicit Client Side Field Level Encryption (CSFLE)

Explicit CSFLE uses the MongoDB driver’s optional encryption library (org.mongodb:mongodb-crypt) to perform encryption and decryption tasks during the mapping process of queries, updates and aggregations ($match stage). Other than automatic encryption there is no need to provide a Schema with encryption information upfront.

The newly introduced @ExplicitEncrypted annotation makes sure to cypher values of annotated properties with a chosen encryption algorithm and Data Encryption Key (DEK) before sending them to the MongoDB server.

@EncryptedField(algorithm="AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic", altKeyName = "secret-key")
String ssn;

Improved ReadPreference & ReadConcern handling

The new API now allows defining both, the ReadPreference, how the client routes an operation to members of a replica set and the ReadConcern, that controls read consistency and isolation level, for queries, aggregations and geo-near operations.

Support for let and pipeline in $lookup aggregation stage

The newly introduced options allow making use of MongoDB’s ability to perform correlated-subqueries which also removes the need for an equality match on the foreign fields.

Aggregation.lookup().from("restaurants")
  .localField("restaurant_name")
  .foreignField("name")
  .let(newVariable("orders_drink").forField("drink"))
  .pipeline(match(ctx -> new Document("$expr", new Document("$in", List.of("$$orders_drink", "$beverages")))))
  .as("matches");

Spring Data Neo4j - 7.1

Spring Data Elasticsearch - 5.1

Spring Data Couchbase - 5.1

Spring Data for Apache Cassandra - 4.1

Spring Data Redis - 3.1

Spring Data KeyValue - 3.1

Spring Data REST - 4.1

Support for returning response bodies when deleting item resources — #2225

RepositoryRestConfiguration now exposes a ….setReturnResponseBodyOnDelete(…) to forcibly enable or disable a response body written when deleting item resources. The default (the option set to null) now considers the Accept header similar to what we already do for POST and PUT requests. If present, a body will be returned alongside a status code of 200. If not, it will stay a 204.

Support for Slice as return type of methods backing query method resources — #2235

Repository methods returning a Slice are now properly turned into a Spring HATEOAS SlicedModel to then render the corresponding SliceMetadata and hypermedia elements to traverse the previous and next slice.

Spring Data LDAP - 3.1

Release Dates

  • M1/M2 - Feb 17, 2023

  • M3 - Mar 17, 2022

  • RC1 - Apr 14, 2022

  • GA - May 12, 2022

  • OSS Support until: May 18, 2024

  • End of Life: Aug 18 2025

Clone this wiki locally