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

unsupported keyword: GREATER_THAN (1): [IsGreaterThan, GreaterThan] #347

Closed
ggthename opened this issue Mar 13, 2019 · 5 comments
Closed

Comments

@ggthename
Copy link

ggthename commented Mar 13, 2019

I'm using Spring JPA + cosmos db.

public interface DeviceTelemetryRepository extends DocumentDbRepository<DeviceTelemetry, String>{

    List<DeviceTelemetry> findAll();

    @Query(value="SELECT * FROM DeviceTelemetry where deviceId= ?1 and date >= ?2 and date <= ?3", nativeQuery = true)
    List<DeviceTelemetry> findDeviceTelemetryByDeviceIdAndDateGreaterThanAndDateLessThan(@Param("deviceId") int deviceId,
                                                               @Param("from") long from,
                                                               @Param("to") long to    );

}
java.lang.IllegalArgumentException: unsupported keyword: GREATER_THAN (1): [IsGreaterThan, GreaterThan]
	at com.microsoft.azure.spring.data.documentdb.repository.query.DocumentDbQueryCreator.from(DocumentDbQueryCreator.java:82) ~[spring-data-cosmosdb-2.0.3.jar:na]
	at com.microsoft.azure.spring.data.documentdb.repository.query.DocumentDbQueryCreator.and(DocumentDbQueryCreator.java:56) ~[spring-data-cosmosdb-2.0.3.jar:na]
	at com.microsoft.azure.spring.data.documentdb.repository.query.DocumentDbQueryCreator.and(DocumentDbQueryCreator.java:25) ~[spring-data-cosmosdb-2.0.3.jar:na]
	at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria(AbstractQueryCreator.java:122) ~[spring-data-commons-2.0.10.RELEASE.jar:2.0.10.RELEASE]
	at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:95) ~[spring-data-commons-2.0.10.RELEASE.jar:2.0.10.RELEASE]
	at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:81) ~[spring-data-commons-2.0.10.RELEASE.jar:2.0.10.RELEASE]
	at com.microsoft.azure.spring.data.documentdb.repository.query.PartTreeDocumentDbQuery.createQuery(PartTreeDocumentDbQuery.java:38) ~[spring-data-cosmosdb-2.0.3.jar:na]
	at com.microsoft.azure.spring.data.documentdb.repository.query.AbstractDocumentDbQuery.execute(AbstractDocumentDbQuery.java:25) ~[spring-data-cosmosdb-2.0.3.jar:na]

Do you have any plan to add GREATER_THAN or BETWEEN ?
If you have alternative way to avoid this exception, please let me know.

Thank you!

@sophiaso
Copy link
Member

@ggthename Thanks for filing issue, according to your stack trace, seems you are using version 2.0.3, if you are using Spring Boot 2.0.x, try upgrading to 2.0.6.

@ggthename
Copy link
Author

ggthename commented Mar 13, 2019

@sophiaso Thank you for your response. I'm using azure-documentdb-spring-boot-starter 2.0.4
It has spring-data-cosmosdb-2.0.3
And azure-documentdb-spring-boot-starter 2.0.5 that has spring-data-cosmosdb-2.0.4 is the latest version.

you mean I need to add 2.0.6 manually. right?
But I think it doesn't have compatibility for azure-documentdb-spring-boot-starter 2.0.5

Correct the classpath of your application so that it contains a single, compatible version of com.microsoft.azure.spring.data.cosmosdb.DocumentDbFactory

=====================================================
when I use azure-documentdb-spring-boot-starter 2.0.5, "GreaterThan" is working.
But the same column is not supported. (e.g. a<=?1 and a>=?2)

com.microsoft.azure.documentdb.DocumentClientException: Message: {"Errors":["Invalid query. Specified duplicate parameter name '@date'."]}

Please let me know, How can I use "Between crateria"
Thank you!

@sophiaso
Copy link
Member

@ggthename You can use the azure-cosmosdb-spring-boot-starter(not azure-documentdb-spring-boot-starter) version 2.0.13, which uses spring-data-cosmosdb 2.0.6. Between should have been supported in 2.0.6, check this issue. Also you can reference the integration tests in this repo for the usage.

@ggthename
Copy link
Author

ggthename commented Mar 14, 2019

@sophiaso Thank you! It works.
I think that it should be modified.
Azure Cosmos DB Starter

Because many people who want to use Azure Cosmos DB can access this page easily.
Can you explain the details?
What is the difference between azure-cosmosdb-spring-boot-starter and azure-documentdb-spring-boot-starter

@sophiaso
Copy link
Member

As the previous azure documentdb brand has been renamed to azure cosmosdb, so the starters and spring-data-cosmosdb is renamed. So please use the new starter azure-cosmosdb-spring-boot-starter, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants