Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does azure-spring-cosmos-data support Specification or querydsl ? #25629

Closed
tkochar opened this issue Nov 23, 2021 · 3 comments
Closed

Does azure-spring-cosmos-data support Specification or querydsl ? #25629

tkochar opened this issue Nov 23, 2021 · 3 comments
Assignees
Labels
azure-spring-cosmos Spring cosmos related issues. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@tkochar
Copy link

tkochar commented Nov 23, 2021

We are using spring data cosmos library to fetch results from cosmosdb and have a requirement to build filter query dynamically. i.e User can filter on any property of a document. Spring provides this capability by using Specifications
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#specifications
I tried to use this with CosmosRepository and getting error while starting application and getting bean creation issue
Repository definition

@Repository
public interface PackageEntityRepository extends CosmosRepository<PackageEntity, String>, JpaSpecificationExecutor<PackageEntity> {
}

Logs
Error creating bean with name 'packageEntityRepository' defined in com.example.artifactmanagement.cosmosdb.entities.PackageEntityRepository defined in @EnableCosmosRepositories declared on CosmosDbConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract org.springframework.data.domain.Page org.springframework.data.jpa.repository.JpaSpecificationExecutor.findAll(org.springframework.data.jpa.domain.Specification,org.springframework.data.domain.Pageable)! Reason: No property findAll found for type PackageEntity!; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type PackageEntity!\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)\n\tat org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1354)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)\n\tat org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)\n\tat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:338)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)

Does azure-spring-cosmos-data support Specification or querydsl ? If no, Do you have any plans to support it in near future.?

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 23, 2021
@chenrujun chenrujun added azure-spring-cosmos Spring cosmos related issues. Cosmos labels Nov 24, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 24, 2021
@kushagraThapar
Copy link
Member

@tkochar - currently we don't provide support for Specification / QueryDSL in azure-spring-data-cosmos SDK. The closest option I can think of is using Criteria API with SqlQuerySpec. Using SqlQuerySpec you can generate CosmosQuery type, which can then be executed using CosmosTemplate or ReactiveCosmosTemplate based on your repository style (sync vs async).

Let me know if this helps.

@manuj20
Copy link

manuj20 commented Apr 14, 2022

Could you provide some sample project link ,how can we use sqlqueryspec with cosmosquery cosmosTemplate Criteria query

@kushagraThapar
Copy link
Member

QueryDSL is not planned to be supported in the near future.
@manuj20 you can refer to these samples. https://github.com/Azure-Samples/azure-spring-boot-samples/tree/main/cosmos/azure-spring-data-cosmos

@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
azure-spring-cosmos Spring cosmos related issues. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants