Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

In this quick guide, we’re going to focus on how to integrate the Spring Data API with the Apache Ignite platform.

To learn about Apache Ignite check out our previous guide.

2. Maven Setup

In addition to the existing dependencies, we have to enable Spring Data support:

<dependency>
    <groupId>org.apache.ignite</groupId>
    <artifactId>ignite-spring-data</artifactId>
    <version>${ignite.version}</version>
</dependency>

The ignite-spring-data artifact can be downloaded from Maven Central.

3. Model and Repository

To demonstrate the integration, we’ll build an application which stores employees into Ignite’s cache by using a Spring Data API.

The POJO of the EmployeeDTO will look like this:

public class EmployeeDTO implements Serializable {
 
    @QuerySqlField(index = true)
    private Integer id;
    
    @QuerySqlField(index = true)
    private String name;
    
    @QuerySqlField(index = true)
    private boolean isEmployed;

    // getters, setters
}

Here, the @QuerySqlField annotation enables querying the fields using SQL.

Next, we’ll create the repository to persist the Employee objects:

@RepositoryConfig(cacheName = "baeldungCache")
public interface EmployeeRepository 
  extends IgniteRepository<EmployeeDTO, Integer> {
    EmployeeDTO getEmployeeDTOById(Integer id);
}

Apache Ignite uses its own IgniteRepository which extends from Spring Data’s CrudRepository. It also enables access to the SQL grid from Spring Data. 

This supports standard CRUD methods, except a few that don’t require an id. We’ll take a look at why in more detail in our testing section.

The @RepositoryConfig annotation maps the EmployeeRepository to Ignite’s baeldungCache.

4. Spring Configuration

Let’s now create our Spring configuration class.

We’ll use the @EnableIgniteRepositories annotation to add support for Ignite repositories:

@Configuration
@EnableIgniteRepositories
public class SpringDataConfig {

    @Bean
    public Ignite igniteInstance() {
        IgniteConfiguration config = new IgniteConfiguration();

        CacheConfiguration cache = new CacheConfiguration("baeldungCache");
        cache.setIndexedTypes(Integer.class, EmployeeDTO.class);

        config.setCacheConfiguration(cache);
        return Ignition.start(config);
    }
}

Here, the igniteInstance() method creates and passes the Ignite instance to IgniteRepositoryFactoryBean in order to get access to the Apache Ignite cluster.

We’ve also defined and set the baeldungCache configuration. The setIndexedTypes() method sets the SQL schema for the cache.

5. Testing the Repository

To test the application, let’s register the SpringDataConfiguration in the application context and get the EmployeeRepository from it:

AnnotationConfigApplicationContext context
 = new AnnotationConfigApplicationContext();
context.register(SpringDataConfig.class);
context.refresh();

EmployeeRepository repository = context.getBean(EmployeeRepository.class);

Then, we want to create the EmployeeDTO instance and save it in the cache:

EmployeeDTO employeeDTO = new EmployeeDTO();
employeeDTO.setId(1);
employeeDTO.setName("John");
employeeDTO.setEmployed(true);

repository.save(employeeDTO.getId(), employeeDTO);

Here we used the save(key, value) method of IgniteRepository. The reason for this is that the standard CrudRepository save(entity), save(entities), delete(entity) operations aren’t supported yet.

The issue behind this is that the IDs generated by the CrudRepository.save() method are not unique in the cluster.

Instead, we have to use the save(key, value), save(Map<ID, Entity> values), deleteAll(Iterable<ID> ids) methods.

After, we can get the employee object from the cache by using Spring Data’s getEmployeeDTOById() method:

EmployeeDTO employee = repository.getEmployeeDTOById(employeeDTO.getId());
System.out.println(employee);

The output shows that we successfully fetched the initial object:

EmployeeDTO{id=1, name='John', isEmployed=true}

Alternatively, we can retrieve the same object using the IgniteCache API:

IgniteCache<Integer, EmployeeDTO> cache = ignite.cache("baeldungCache");
EmployeeDTO employeeDTO = cache.get(employeeId);

Or by using the standard SQL:

SqlFieldsQuery sql = new SqlFieldsQuery(
  "select * from EmployeeDTO where isEmployed = 'true'");

6. Summary

This short tutorial shows how to integrate the Spring Data Framework with the Apache Ignite project. With the help of the practical example, we learned to work with the Apache Ignite cache by using the Spring Data API.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW