The primary goal of the Spring Data is to make it easier to build Spring-powered applications that use new data access technologies. This module provides integration with Hazelcast.
For examples on using Spring Data Hazelcast, see dedicated Code Samples: spring-data-hazelcast-chemistry-sample and spring-data-jpa-hazelcast-migration.
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>spring-data-hazelcast</artifactId>
<version>${version}</version>
</dependency>dependencies {
compile 'com.hazelcast:spring-data-hazelcast:${version}'
}| Spring Data Hazelcast | Spring Boot | Spring Data | Hazelcast | Java |
|---|---|---|---|---|
| 2.4.x | 3.x | 2021.x | 4.x - 5.x | 11+ |
| 4.1.x | 4.x | 2026.0.x | 5.6 - 5.7 | 17+ |
Spring Data Commons relocated PropertyPath to org.springframework.data.core in the release
train shipped with Spring Boot 4, so a single artifact cannot serve both baselines. Applications
staying on Spring Boot 3.x must stay on the 2.4.x line.
@Configuration
@EnableHazelcastRepositories(basePackages={"example.springdata.keyvalue.chemistry"}) // <1>
public class ApplicationConfiguration {
@Bean
HazelcastInstance hazelcastInstance() { // <2>
return Hazelcast.newHazelcastInstance();
// return HazelcastClient.newHazelcastClient();
}
}- Enables Spring Data magic for Hazelcast. You can specify
basePackagesfor component scan. - Instantiates Hazelcast instance (a member or a client)
public interface SpeakerRepository extends HazelcastRepository<Speaker, Long> {}@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = AppConfiguration.class)
public class AppTest {
@Autowired
SpeakerRepository speakerRepository;
@Test
public void testStart(){
speakerRepository.findAll();
}
}@Query("firstname=James")
public List<Person> peopleWithTheirFirstNameIsJames();@Query("firstname=%s")
public List<Person> peopleWithTheirFirstName(String firstName);@Query("firstname=%s and lastname=%s")
public List<Person> peopleWithFirstAndLastName(String firstName,String lastName);True
False
Equal
NotEqual
Before
LessThan
LessThanEqual
After
GreaterThan
GreaterThanEqual
Between
IsNull
IsNotNull
In
NotIn
Containing
NotContaining
StartingWith
EndingWith
Like
NotLike
Regex
Distinct
IsEmpty
ExistsBy
IsWithin
IsNear