Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ All the sessions are delivered by seasoned Ignite experts and committers.
* [httpie](https://httpie.io)
* A web browser

### Note 1
### Note

This project has been tested most thoroughly using Java 17 and GridGain 9.1.8. (GridGain 9 supports Java 11, but the minimum version for Spring Boot is Java 17.) Later versions _may_ work; earlier versions will not. We test most frequently on Macs, but it should also work on Windows and Linux machines. Please create an Issue (or a PR!) if you find any issues.

### Note 2

This project currently uses Spring Boot and Data 3.x. GridGain 9.1.19 and higher supports Spring 4.x.
This project has been tested most thoroughly using Java 17 and GridGain 9.1.19. (GridGain 9 supports Java 11, but the minimum version for Spring Boot is Java 17.) Later versions _may_ work; earlier versions will not. We test most frequently on Macs, but it should also work on Windows and Linux machines. Please create an Issue (or a PR!) if you find any issues.

## Hands-on part 1

Expand All @@ -53,7 +49,7 @@ git clone https://github.com/GridGain-Demos/spring-data-training.git
a. Start the Command Line Interface (CLI):

```bash
docker run -v ./gridgain-license.json:/opt/gridgain/downloads/gridgain-license.json -v ./config/world.sql:/opt/gridgain/downloads/world.sql --rm --network spring-boot-data-training_default -it gridgain/gridgain9:9.1.8 cli
docker run -v ./gridgain-license.json:/opt/gridgain/downloads/gridgain-license.json -v ./config/world.sql:/opt/gridgain/downloads/world.sql --rm --network spring-boot-data-training_default -it gridgain/gridgain9:9.1.19 cli
```
(Ensure your license file is in your current directory.)

Expand Down Expand Up @@ -181,7 +177,6 @@ Leave the CLI connected to the cluster.
@Test
void countryRepositoryWorks() {
var results = countryRepository.findByPopulationGreaterThanOrderByPopulationDesc(100_000_000);
System.out.println("count=" + results.size());
Assertions.assertTrue(results.size() > 0);
}
```
Expand All @@ -202,7 +197,7 @@ Leave the CLI connected to the cluster.

```java
@Repository
public interface CityRepository extends CrudRepository<City, Integer> {
public interface CityRepository extends CrudRepository<City, CityKey> {
}
```

Expand All @@ -223,9 +218,9 @@ Leave the CLI connected to the cluster.
```java
@Test
void cityRepositoryWorks() {
var city = cityRepository.findById(34);
var city = cityRepository.findById(new CityKey(34, "ALB"));
Assertions.assertTrue(city.isPresent());
Assertions.assertEquals("Tirana", city.get().getName());
Assertions.assertEquals("Tirana", city.get().name());

var populatedCities = cityRepository.findTopXMostPopulatedCities(5);
Assertions.assertEquals(5, populatedCities.size());
Expand Down
4 changes: 2 additions & 2 deletions config/world.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ CREATE TABLE City (
CountryCode VARCHAR(3),
District VARCHAR,
Population INT,
PRIMARY KEY (ID)
);
PRIMARY KEY (ID, CountryCode)
) COLOCATE BY (CountryCode);

CREATE INDEX idx_country_code ON city (CountryCode);

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: spring-boot-data-training

x-gridgain-def:
&gridgain-def
image: gridgain/gridgain9:9.1.8
image: gridgain/gridgain9:9.1.19-openjdk21
environment:
JVM_MAX_MEM: "4g"
JVM_MIN_MEM: "4g"
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.11</version>
<version>4.0.3</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.gridgain.training</groupId>
Expand All @@ -15,7 +15,7 @@
<properties>
<java.version>17</java.version>
<ignite.project>org.gridgain</ignite.project>
<ignite.version>9.1.8</ignite.version>
<ignite.version>9.1.19</ignite.version>
</properties>

<repositories>
Expand Down
73 changes: 1 addition & 72 deletions src/main/java/com/gridgain/training/spring/model/City.java
Original file line number Diff line number Diff line change
@@ -1,77 +1,6 @@
package com.gridgain.training.spring.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;

public class City {
@Id
private Integer id;

@Column(value = "COUNTRYCODE")
private String countryCode;

private String name;

private String district;

private Integer population;

public City() {
}

public City(Integer id, String countryCode, String name, String district, Integer population) {
this.id = id;
this.countryCode = countryCode;
this.name = name;
this.district = district;
this.population = population;
}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getCountryCode() {
return countryCode;
}

public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDistrict() {
return district;
}

public void setDistrict(String district) {
this.district = district;
}

public Integer getPopulation() {
return population;
}

public void setPopulation(Integer population) {
this.population = population;
}

@Override public String toString() {
return "City{" +
"name='" + name + '\'' +
", district='" + district + '\'' +
", population=" + population +
'}';
}
public record City (@Id CityKey id, String name, String district, Integer population) {
}
6 changes: 6 additions & 0 deletions src/main/java/com/gridgain/training/spring/model/CityKey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.gridgain.training.spring.model;

import org.springframework.data.relational.core.mapping.Column;

public record CityKey (Integer id, @Column(value = "COUNTRYCODE") String countryCode) {
}