spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

Sprintboot/Datastore - FindAll(example, pageable) #2611

Closed beunick closed 3 years ago

beunick commented 3 years ago

Hello mate,

I am using Springboot and Datastore and I am having problem with findAll(example, pageable). The problem is the findAll(example, pageable) is not returning the data based on the example, but instead return everything. Here is a piece of my code.

Entity Product I have this : `@Entity(name="product") public class Product {

@Id
private Key id;

@Reference
private Store store;

// SETTER AND GETTER

}`

Entity Store:

`@Entity(name="store") public class Store {

@Id
private Key id;

private String name;

// SETTER AND GETTER

}`

Product Repository: @Repository public interface ProductRepository extends DatastoreRepository<Product, Key> { }

In my service I have Pageable pageable = PageRequest.of(0, 3); Product product = new Product(); product.setStore(store); Example<Product> example = Example.of(product); Page<Product> pagedProduct = this.productRepository.findAll(example, pageable);

The findAll return everything in the Product table instead of only returning the data based on the example. Can you please let me know if you know why ? Thank You

meltsufin commented 3 years ago

This might be a bug. @dmitry-s PTAL when you have a chance.

beunick commented 3 years ago

Thanks for the note @meltsufin, so what is the next step ? How long do you think it may take to resolve it ? Thank You. By the way my primary Key is based on UUID.

Thanks.

meltsufin commented 3 years ago

@dmitry-s Was out today, but he should be able to assess tomorrow. Thanks for you patience.

beunick commented 3 years ago

Thank You :)

dmitry-s commented 3 years ago

I was able to replicate the issue, working on a fix.

beunick commented 3 years ago

Thank you

beunick commented 3 years ago

Thank You @dmitry-s can you please let me know which version include this fix ? Thanks

meltsufin commented 3 years ago

This will be released in 1.2.7 and 2.0.0.

beunick commented 3 years ago

Do you know when the release will be available ? Because when I use 1.2.7 in my POM file I have an error. Thank You!

meltsufin commented 3 years ago

There is no date for 1.2.7, as it's dependent on the next Spring Cloud Hoxton service release, but 2.0.0 will be coming soon (a few weeks). In the meantime, you can use 1.2.7.BUILD-SNAPSHOT if you add Spring Snapshots repository.

beunick commented 3 years ago

Thanks @meltsufin for the note. I add the Spring Snapshots Repository and use 1.2.7.BUILD-SNAPSHOT but here is the error I am getting when I build the application: [ERROR] Failed to execute goal on project aggregrator: Could not resolve dependencies for project co.pro.aggregrator:aggregrator:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.springframework.cloud:spring-cloud-gcp-starter-data-datastore:jar:1.2.7.BUILD-SNAPSHOT: Failed to read artifact descriptor for org.springframework.cloud:spring-cloud-gcp-starter-data-datastore:jar:1.2.7.BUILD-SNAPSHOT: Could not transfer artifact org.springframework.cloud:spring-cloud-gcp-starter-data-datastore:pom:1.2.7.BUILD-SNAPSHOT from/to repository.spring.snapshot (http://repo.spring.io/snapshot): Access denied to http://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-gcp-starter-data-datastore/1.2.7.BUILD-SNAPSHOT/spring-cloud-gcp-starter-data-datastore-1.2.7.BUILD-SNAPSHOT.pom. Error code 403, Forbidden -> [Help 1]

Here is what I have in my POM file, is there something I am doing wrong ?

    <repositories>
        <repository> 
            <id>repository.spring.snapshot</id> 
            <name>Spring Snapshot Repository</name> 
            <url>http://repo.spring.io/snapshot</url> 
        </repository>
    </repositories>

...
...

      <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-gcp-starter-data-datastore</artifactId>
                <version>1.2.7.BUILD-SNAPSHOT</version>
      </dependency>
meltsufin commented 3 years ago

Please use this one:

                <repository>
                    <id>spring-snapshots</id>
                    <name>Spring Snapshots</name>
                    <url>https://repo.spring.io/libs-snapshot-local</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                </repository>

I just tested it, and it found the artifact.