Skip to content

Commit

Permalink
FMWK-119 Upgrade to Spring Data 3 (#478)
Browse files Browse the repository at this point in the history
* code update to work with Spring Data 3

* update to work with Spring Data 3

* update to work with Spring Data 3

* update to work with Spring Data 3

* project version update, minor cleanup

* minor cleanup

* readme update

* update for build.yml

* readme and required-labels updates

* readme update

* javadoc update

* javadoc version update
  • Loading branch information
agrgr authored Jan 30, 2023
1 parent 99ed5fb commit f87543f
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
java-version: 17

# See: https://github.com/actions/cache/blob/main/examples.md#java---maven
- name: Maven cache and restore deps
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
java-version: 17
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/required-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
name: Verify Pull Request has labels
steps:
- uses: mheap/github-action-required-labels@v2
- uses: mheap/github-action-required-labels@v3
with:
mode: minimum
count: 1
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ The documentation for this project can be found on [javadoc.io](https://www.java

## Spring Data Aerospike compatibility

|Spring Data Aerospike | Spring Boot | Aerospike Client | Aerospike Reactor Client | Aerospike Server
| :----------- | :---- | :----------- | :----------- | :-----------
|3.5.x | 2.7.x | 6.1.x | 6.1.x | 5.2.x.x +
|3.4.x | 2.6.x | 5.1.x | 5.1.x | 5.2.x.x +
|3.3.x | 2.5.x | 5.1.x | 5.1.x | 5.2.x.x +
|3.2.x | 2.5.x | 5.1.x | 5.0.x | 5.2.x.x +
|3.0.x, 3.1.x | 2.5.x | 5.1.x | 5.0.x
|2.5.x | 2.5.x | 4.4.x | 4.4.x
|2.4.2.RELEASE | 2.3.x | 4.4.x | 4.4.x
|2.3.5.RELEASE | 2.2.x | 4.4.x | 4.4.x
|2.1.1.RELEASE | 2.1.x, 2.0.x | 4.4.x | 3.2.x
|1.2.1.RELEASE | 1.5.x | 4.1.x |
| Spring Data Aerospike | Spring Boot | Aerospike Client | Aerospike Reactor Client | Aerospike Server
|:----------------------|:-------------|:-----------------|:-------------------------| :-----------
| 4.0.x | 3.0.x | 6.1.x | 6.1.x | 5.2.x.x +
| 3.5.x | 2.7.x | 6.1.x | 6.1.x | 5.2.x.x +
| 3.4.x | 2.6.x | 5.1.x | 5.1.x | 5.2.x.x +
| 3.3.x | 2.5.x | 5.1.x | 5.1.x | 5.2.x.x +
| 3.2.x | 2.5.x | 5.1.x | 5.0.x | 5.2.x.x +
| 3.0.x, 3.1.x | 2.5.x | 5.1.x | 5.0.x
| 2.5.x | 2.5.x | 4.4.x | 4.4.x
| 2.4.2.RELEASE | 2.3.x | 4.4.x | 4.4.x
| 2.3.5.RELEASE | 2.2.x | 4.4.x | 4.4.x
| 2.1.1.RELEASE | 2.1.x, 2.0.x | 4.4.x | 3.2.x
| 1.2.1.RELEASE | 1.5.x | 4.1.x |

## Quick Start

Expand All @@ -56,7 +57,7 @@ Add the Maven dependency:
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>spring-data-aerospike</artifactId>
<version>3.5.0</version>
<version>4.0.0</version>
</dependency>
```

Expand Down
47 changes: 35 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.aerospike</groupId>
<artifactId>spring-data-aerospike</artifactId>
<version>3.5.0</version>
<version>4.0.0</version>
<name>Spring Data Aerospike</name>
<organization>
<name>Aerospike Inc.</name>
Expand All @@ -16,24 +16,28 @@
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>2.7.5</version>
<version>3.0.1</version>
</parent>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<springdata.commons>2.7.5</springdata.commons>
<springdata.keyvalue>2.7.5</springdata.keyvalue>
<spring-cloud-starter-bootstrap>3.1.4</spring-cloud-starter-bootstrap>
<spring-boot-starter-test>2.7.5</spring-boot-starter-test>
<springdata.commons>3.0.1</springdata.commons>
<springdata.keyvalue>3.0.1</springdata.keyvalue>
<spring-cloud-starter-bootstrap>4.0.0</spring-cloud-starter-bootstrap>
<spring-boot-starter-test>3.0.2</spring-boot-starter-test>
<maven.javadoc.plugin>3.3.0</maven.javadoc.plugin>
<maven.gpg.plugin>1.6</maven.gpg.plugin>
<aerospike>6.1.3</aerospike>
<aerospike>6.1.6</aerospike>
<aerospike-reactor>6.1.2</aerospike-reactor>
<embedded-aerospike>2.2.10</embedded-aerospike>
<awaitility>4.2.0</awaitility>
<reactor-test>3.4.24</reactor-test>
<embedded-aerospike>2.2.14</embedded-aerospike>
<jodatime>2.12.2</jodatime>
<lombok>1.18.24</lombok>
<awaitility>4.2.0</awaitility>
<logback.test>1.4.5</logback.test>
<hibernate.validator>8.0.0.Final</hibernate.validator>
</properties>

<licenses>
Expand Down Expand Up @@ -244,6 +248,7 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<version>${reactor-test}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -270,6 +275,24 @@
<version>${awaitility}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.test}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.test}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -303,7 +326,7 @@
<splitindex>true</splitindex>
<bottom>Copyright &#169; 2020&#x2013;{currentYear} Aerospike, Inc. All rights reserved.</bottom>
<sourcepath>${basedir}/src/main/java</sourcepath>
<source>1.8</source>
<source>17</source>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.keyvalue.core.IterableConverter;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.util.Assert;

Expand All @@ -31,7 +32,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class SimpleAerospikeRepository<T, ID> implements AerospikeRepository<T, ID> {
public class SimpleAerospikeRepository<T, ID> implements AerospikeRepository<T, ID>, CrudRepository<T, ID> {

private final AerospikeOperations operations;
private final EntityInformation<T, ID> entityInformation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,9 @@ public void findByAgeGreaterThan_forExistingResult() {

@Test
public void findPersonsSomeFieldsByAgeGreaterThan_forExistingResultProjection() {
Slice<PersonSomeFields> slice = repository.findPersonSomeFieldsByAgeGreaterThan(40, PageRequest.of(0, 10));
Slice<PersonSomeFields> slice = repository.findPersonSomeFieldsByAgeGreaterThan(
40, PageRequest.of(0, 10)
);

assertThat(slice.hasContent()).isTrue();
assertThat(slice.hasNext()).isFalse();
Expand All @@ -501,7 +503,9 @@ public void findByAgeGreaterThan_respectsLimit() {
@Test
public void findByAgeGreaterThan_respectsLimitAndOffsetAndSort() {
List<Person> result = IntStream.range(0, 4)
.mapToObj(index -> repository.findByAgeGreaterThan(40, PageRequest.of(index, 1, Sort.by("age"))))
.mapToObj(index -> repository.findByAgeGreaterThan(40, PageRequest.of(
index, 1, Sort.by("age")
)))
.flatMap(slice -> slice.getContent().stream())
.collect(Collectors.toList());

Expand Down Expand Up @@ -591,7 +595,9 @@ public void findPersonsByFriendFirstnameStartsWith() {

@Test
public void findPagedPersons() {
Page<Person> result = repository.findAll(PageRequest.of(1, 2, Sort.Direction.ASC, "lastname", "firstname"));
Page<Person> result = repository.findAll(PageRequest.of(
1, 2, Sort.Direction.ASC, "lastname", "firstname")
);
assertThat(result.isFirst()).isFalse();
assertThat(result.isLast()).isFalse();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ public Object[] getValues() {
return this.values;
}

/**
* @deprecated
*/
@Override
public Optional<Class<?>> getDynamicProjection() {
return Optional.empty();
}

@Override
public Class<?> findDynamicProjection() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
package org.springframework.data.aerospike.sample;

import org.springframework.data.aerospike.repository.AerospikeRepository;
import org.springframework.data.repository.CrudRepository;

public interface CompositeObjectRepository extends AerospikeRepository<CompositeObject, String> {

}
public interface CompositeObjectRepository extends AerospikeRepository<CompositeObject, String>,
CrudRepository<CompositeObject, String> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
package org.springframework.data.aerospike.sample;

import org.springframework.data.aerospike.repository.AerospikeRepository;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
* @author Oliver Gierke
*/
public interface CustomerRepository extends AerospikeRepository<Customer, String> {
public interface CustomerRepository extends AerospikeRepository<Customer, String>, CrudRepository<Customer, String> {

List<Customer> findByLastName(String lastName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.CrudRepository;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -33,7 +34,7 @@
* @author Peter Milne
* @author Jean Mercier
*/
public interface PersonRepository<P extends Person> extends AerospikeRepository<P, String> {
public interface PersonRepository<P extends Person> extends AerospikeRepository<P, String>, CrudRepository<P, String> {

List<P> findByLastName(String lastName);

Expand Down Expand Up @@ -208,15 +209,17 @@ public interface PersonRepository<P extends Person> extends AerospikeRepository<
List<P> findByStringMapContaining(String key, String valuePart);

/**
* Find all entities that satisfy the condition "have the given map key and a value that is greater than the given integer"
* Find all entities that satisfy the condition "have the given map key and a value that is greater
* than the given integer"
*
* @param key Map key
* @param greaterThan integer to check if value is greater than it
*/
List<P> findByIntMapGreaterThan(String key, int greaterThan);

/**
* Find all entities that satisfy the condition "have the given map key and a value that is less than or equal to the given integer"
* Find all entities that satisfy the condition "have the given map key and a value that is less than
* or equal to the given integer"
*
* @param key Map key
* @param lessThanOrEqualTo integer to check if value satisfies the condition
Expand All @@ -235,28 +238,32 @@ public interface PersonRepository<P extends Person> extends AerospikeRepository<
List<P> findByFriendLastName(String value);

/**
* Find all entities that satisfy the condition "have a friend with the age equal to the given integer" (find by POJO field)
* Find all entities that satisfy the condition "have a friend with the age equal to the given integer"
* (find by POJO field)
*
* @param value - number to check for equality
*/
List<P> findByFriendAge(int value);

/**
* Find all entities that satisfy the condition "have a friend with the age NOT equal to the given integer" (find by POJO field)
* Find all entities that satisfy the condition "have a friend with the age NOT equal to the given integer"
* (find by POJO field)
*
* @param value - number to check for inequality
*/
List<P> findByFriendAgeIsNot(int value);

/**
* Find all entities that satisfy the condition "have a friend with the age greater than the given integer" (find by POJO field)
* Find all entities that satisfy the condition "have a friend with the age greater than the given integer"
* (find by POJO field)
*
* @param value - lower limit, exclusive
*/
List<P> findByFriendAgeGreaterThan(int value);

/**
* Find all entities that satisfy the condition "have a friend with the age less than or equal to the given integer" (find by POJO field)
* Find all entities that satisfy the condition "have a friend with the age less than
* or equal to the given integer" (find by POJO field)
*
* @param value - upper limit, inclusive
*/
Expand Down Expand Up @@ -301,7 +308,8 @@ public interface PersonRepository<P extends Person> extends AerospikeRepository<
List<P> findByIntsGreaterThan(int integer);

/**
* Find all entities that satisfy the condition "have at least one list value which is less than or equal to the given integer"
* Find all entities that satisfy the condition "have at least one list value which is less than
* or equal to the given integer"
* <p>
* List name in this case is Ints
* </p>
Expand All @@ -311,7 +319,8 @@ public interface PersonRepository<P extends Person> extends AerospikeRepository<
List<P> findByIntsLessThanEqual(int integer);

/**
* Find all entities that satisfy the condition "have at least one list value which is less than or equal to the given long"
* Find all entities that satisfy the condition "have at least one list value which is less than
* or equal to the given long"
* <p>
* List name in this case is Ints
* </p>
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/bootstrap.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
embedded.aerospike.dockerImage=aerospike/aerospike-server:6.1.0.3
embedded.aerospike.dockerImage=aerospike/aerospike-server:6.1.0.7

0 comments on commit f87543f

Please sign in to comment.