Return to site

🍃💾 SPRING DATA 2026.0 IS GA: SAFER PATHS, REDIS LISTENERS, BULK WRITES & UPSERTS

· spring

Spring Data 2026.0, also known as Spring Data 4.1, is now generally available from Maven Central. 🎉

This release train is not just about version numbers.

It brings practical improvements for backend developers working with repositories, Redis Pub/Sub, MongoDB bulk operations, JDBC, and R2DBC.

🔸 TL;DR

Spring Data 2026.0 improves developer experience and persistence efficiency with:

▪️ Type-safe property paths

▪️ Annotation-driven Redis Pub/Sub listeners

▪️ Migration to UnifiedJedis

▪️ MongoDB multi-collection bulk writes

▪️ Single-statement upsert for JDBC and R2DBC aggregate roots

Section image

🔸 1️⃣ TYPE-SAFE PROPERTY PATHS

Query query = query(
    where(TypedPropertyPath
        .of(Customer::getAddress)
        .then(Address::getCity))
    .is("Lille")
);

query.with(Sort.by(Customer::getLastname, Customer::getFirstname));

No more fragile "address.city" strings everywhere. With type-safe property paths, refactoring becomes safer because property references are linked to your Java model instead of raw strings. ✅

🔸 2️⃣ REDIS PUB/SUB LISTENERS

@Configuration
@EnableRedisListeners
class RedisConfig {

    @Bean
    RedisMessageListenerContainer redisMessageListenerContainer(
            RedisConnectionFactory connectionFactory) {

        RedisMessageListenerContainer container =
                new RedisMessageListenerContainer();

        container.setConnectionFactory(connectionFactory);
        return container;
    }
}

@Component
class OrderEvents {

    @RedisListener(topic = "orders.created", consumes = "application/json")
    void onOrderCreated(OrderCreated event) {
        // process Redis Pub/Sub message
    }
}

Spring Data Redis 4.1 introduces annotation-driven Pub/Sub listeners. Instead of wiring listeners manually, you can declare intent directly with @RedisListener.

Also worth noting: when using Jedis, Spring Data Redis now moves toward UnifiedJedis, giving access to newer Jedis features and replacing older Jedis/JedisCluster-based APIs. 🔴

🔸 3️⃣ MONGODB MULTI-COLLECTION BULK WRITES

Bulk bulk = Bulk.create(builder -> builder

    .inCollection(Jedi.class, spec -> spec
        .insert(new Jedi("Luke", "Skywalker"))
        .insert(new Jedi("Leia", "Princess"))
        .updateOne(
            where("firstname").is("Leia"),
            new Update().set("lastname", "Organa")
        )
    )

    .inCollection(Sith.class, spec -> spec
        .upsert(
            where("name").is("Darth Sidious"),
            Update.update("realName", "Palpatine")
        )
    )
);

BulkWriteResult result =
    operations.bulkWrite(bulk, BulkWriteOptions.ordered());

Spring Data MongoDB 5.1 revises the Bulk API. You can group mixed operations and, with MongoDB 8.0+, issue bulk writes across multiple collections in one request. ⚡

🔸 4️⃣ JDBC AND R2DBC SINGLE-STATEMENT UPSERT

Bulk bulk = Bulk.create(builder -> builder

    .inCollection(Jedi.class, spec -> spec
        .insert(new Jedi("Luke", "Skywalker"))
        .insert(new Jedi("Leia", "Princess"))
        .updateOne(
            where("firstname").is("Leia"),
            new Update().set("lastname", "Organa")
        )
    )

    .inCollection(Sith.class, spec -> spec
        .upsert(
            where("name").is("Darth Sidious"),
            Update.update("realName", "Palpatine")
        )
    )
);

BulkWriteResult result =
    operations.bulkWrite(bulk, BulkWriteOptions.ordered());

Spring Data JDBC and R2DBC can now persist an aggregate root with one upsert statement when the identifier is already known.

The database decides:

▪️ insert if the row does not exist

▪️ update if the row already exists

Under the hood, the generated SQL is dialect-specific, for example MERGE, INSERT ... ON CONFLICT, or INSERT ... ON DUPLICATE KEY UPDATE. 🧱

🔸 TAKEAWAYS

▪️ Use type-safe property paths to reduce refactoring bugs.

▪️ Use @RedisListener when Redis Pub/Sub fits your architecture.

▪️ Check your Jedis usage because older Jedis constructors are being deprecated.

▪️ Use MongoDB bulk writes when you need grouped write operations, especially across collections.

▪️ Use JDBC/R2DBC upsert carefully: the aggregate root must already have an ID.

▪️ Do not assume upsert replaces all save logic: review locking, dialect support, and domain rules.

Spring Data 2026.0 is not a “rewrite your app” release. It is a “remove boilerplate, reduce stringly-typed code, and make persistence operations more explicit” release. 💡

#SpringData #SpringFramework #Java #SpringBoot #Redis #MongoDB #JDBC #R2DBC #BackendDevelopment #JavaDeveloper #SoftwareEngineering

Go further with Java certification:

Java👇

Spring👇

SpringBook👇

JavaBook👇