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

Caused by: java.lang.IllegalArgumentException: BETWEEN (2): [IsBetween, Between] is not supported for Redis query derivation! [DATAREDIS-1148] #1719

Closed
spring-projects-issues opened this issue May 17, 2020 · 1 comment
Assignees
Labels
in: repository Repositories abstraction status: declined A suggestion or change that we don't feel we should currently apply type: bug A general bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented May 17, 2020

Raghunandan Chakravarthy opened DATAREDIS-1148 and commented

I'm currently developing a Srping Boot + Redis application. I'm trying to query for records between two given dates. 

The repository method "findByCreatedAtBetween" when accessed throws the following error.

Caused by: java.lang.IllegalArgumentException: BETWEEN (2): [IsBetween, Between] is not supported for Redis query derivation!Caused by: java.lang.IllegalArgumentException: BETWEEN (2): [IsBetween, Between] is not supported for Redis query derivation! at org.springframework.data.redis.repository.query.RedisQueryCreator.from(RedisQueryCreator.java:73) ~[spring-data-redis-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.redis.repository.query.RedisQueryCreator.create(RedisQueryCreator.java:53) ~[spring-data-redis-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.redis.repository.query.RedisQueryCreator.create(RedisQueryCreator.java:41) ~[spring-data-redis-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria(AbstractQueryCreator.java:119) ~[spring-data-commons-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:95) ~[spring-data-commons-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:81) ~[spring-data-commons-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.createQuery(KeyValuePartTreeQuery.java:212) ~[spring-data-keyvalue-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.prepareQuery(KeyValuePartTreeQuery.java:149) ~[spring-data-keyvalue-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.execute(KeyValuePartTreeQuery.java:107) ~[spring-data-keyvalue-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:618) ~[spring-data-commons-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605) ~[spring-data-commons-2.2.6.RELEASE.jar:2.2.6.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] at com.sun.proxy.$Proxy122.findByCreatedAtBetween(Unknown Source) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.2.5.RELEASE.jar:5.2.5.RELEASE] ... 92 common frames omitted

 

TransactionStatsRepository.java

 

public interface TransactionStatsRepository extends CrudRepository<TransactionStats, String> {
    List<TransactionStats> findByCreatedAtBetween(Date startDate, Date endDate);
}

TransactionStats.java

 

 

@RedisHash("TRANSACTION")
public class TransactionStats implements Serializable {

    @Id
    private String id;

    @Indexed
    private String status;

    @Indexed
    private Date createdAt;

//Getters and Setters

TransactionStatsService.java

 

//Insertion of Data
    public void addNewTransaction(String status, String createdAt) throws      ParseException {
        TransactionStats stats = new TransactionStats();
        stats.setStatus(status);
        stats.setCreatedAt(getStringToDate(createdAt));
        transactionStatsRepository.save(stats);
    }

    private Date getStringToDate(String dateString) throws ParseException {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        formatter.setTimeZone(TimeZone.getTimeZone("GMT" + timeZoneOffset));
        return formatter.parse(dateString);
    }

//Data Retrieval
    public List<TransactionStatsDTO> getForDuration(String startDuration, String endDuration) throws ParseException {
        Date startDate = getStringToDate(startDuration);
        Date endDate = getStringToDate(endDuration);
        List<TransactionStatsDTO> transactionStatsDTOs = new ArrayList<>();
        transactionStatsRepository.findByCreatedAtBetween(startDate, endDate)
                .forEach(transactionStats -> transactionStatsDTOs.add(mapper.map(transactionStats, TransactionStatsDTO.class)));
        return transactionStatsDTOs;
    }

Since Redis doesn't allow querying data in range as I've done, is there a way to retrieve the data in a date range?


Reference URL: https://stackoverflow.com/questions/61839726/between-2-isbetween-between-is-not-supported-for-redis-query-derivation

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented May 18, 2020

Mark Paluch commented

Redis Repositories support only a small number of supported keywords. The between keyword (and a lot of others) are not supported. Please see the reference documentation for all supported query keywords

@spring-projects-issues spring-projects-issues added type: bug A general bug status: declined A suggestion or change that we don't feel we should currently apply in: repository Repositories abstraction labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository Repositories abstraction status: declined A suggestion or change that we don't feel we should currently apply type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants