GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp

ClassCastException when using Slice<T> or Page<T> in SpannerRepository

Open
#600 4 comments 1 reaction 0 assignees View on GitHub
priority: p2 spanner type: enhancement
Dominant language
Java
Stars
551
Forks
349
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**Issue**
When using Slice or Page in the repository I get a ClassCastException.

```
java.lang.ClassCastException: class x.y.z.MyEntityClass cannot be cast to class org.springframework.data.domain.Page (x.y.z.MyEntityClass and org.springframework.data.domain.Page are in unnamed module of loader 'app')
at jdk.proxy2/jdk.proxy2.$Proxy76.findByProcessingDateTimeLessThanEqual(Unknown Source)
```

Example:
```
public interface MyRepository extends SpannerRepository {
Page findAllByProcessingDateTimeLessThanEqual(final Timestamp processingDateLte, final Pageable pageable);
}
```

When I change it to List, I get a result without error.

Dependencies:

```
dependencyManagement {
imports {
mavenBom "com.google.cloud:spring-cloud-gcp-dependencies:2.0.4"
}
}

dependencies {
...
implementation "com.google.cloud:spring-cloud-gcp-starter-data-spanner"
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.