Skip to content
Hazelcast Spring Data integration Project http://projects.spring.io/spring-data/
Java
Branch: master
Clone or download
Latest commit a53c13e Nov 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
checkstyle Reformat code and clean up the licenses in files May 30, 2018
src Meeting with the new implementation in spring boot 2.2.0.RELEASE to r… Oct 21, 2019
.gitignore added sources and javadocs plugin Aug 3, 2016
LICENSE
README.md
pom.xml 2.2.3-SNAPSHOT Nov 8, 2019
template.mf Make the change backward compatible May 16, 2018

README.md

Spring Data Hazelcast

Welcome to Spring Data Hazelcast project!

The primary goal of the Spring Data project is to make it easier to build Spring-powered applications that use new data access technologies. This module provides integration with Hazelcast.

Examples

For examples on using Spring Data Hazelcast, see dedicated Code Samples: spring-data-hazelcast-chemistry-sample and spring-data-jpa-hazelcast-migration.

Artifacts

Maven

<dependency>
    <groupId>com.hazelcast</groupId>
    <artifactId>spring-data-hazelcast</artifactId>
    <version>${version}</version>
</dependency>

Gradle

dependencies {
    compile 'com.hazelcast:spring-data-hazelcast:${version}'
}

Usage

Spring Configuration

@Configuration
@EnableHazelcastRepositories(basePackages={"example.springdata.keyvalue.chemistry"}) // <1>
public class ApplicationConfiguration {
    @Bean
    HazelcastInstance hazelcastInstance() {     // <2> 
        return Hazelcast.newHazelcastInstance();
        // return HazelcastClient.newHazelcastClient();
    }
}
  1. Enables Spring Data magic for Hazelcast. You can specify basePackages for component scan.
  2. Instantiates Hazelcast instance (a member or a client)

Repository Definition

public interface SpeakerRepository extends HazelcastRepository<Speaker, Long> {}

Test of Repository

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = AppConfiguration.class)
public class AppTest {
    @Autowired
    SpeakerRepository speakerRepository;

    @Test
    public void testStart(){
        speakerRepository.findAll();
    }
}

@Query Support

Sample @Query Usages

Query with hardcoded value

@Query("firstname=James")
public List<Person> peoplewiththeirFirstNameIsJames();

Query with one variable

@Query("firstname=%s")
public List<Person> peoplewiththeirFirstName(String firstName);

Query with multiple variable values

@Query("firstname=%s and lastname=%s")
public List<Person> peoplewithFirstAndLastName(String firstName,String lastName);

Supported Query Keywords

True
False
Equal
NotEqual
Before
LessThan
LessThanEqual
After
GreaterThan
GreaterThanEqual
Between
IsNull
IsNotNull
In
NotIn
Containing
NotContaining
StartingWith
EndingWith
Like
NotLike
Regex

Community

Chat with developers

Gitter

Stack Overflow

Stack Overflow

Submit your question with hazelcast and spring-data-hazelcast tags.

Mail Group

Please, join the mail group if you are interested in using or developing Hazelcast.

License

Hazelcast is available under the Apache 2 License. Please see the Licensing appendix for more information.

Copyright

Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved.

Visit http://www.hazelcast.com for more information.

You can’t perform that action at this time.