I am having trouble writing a JPAQuery that will execute a simple less than or equal to comparison on an integer column. I have QCommand generated querydsl object which I am trying to use with a JPAquery to execute this very simple query. The query I want to execute would look like this using SQL:
select * from command where retry_count <= 10;
The generated QCommand object defines the retryCount parameter as:
public final SimplePath<Integer> retryCount = createSimple("retryCount", Integer.class);
I have noticed that because it is a SimplePath, when I try to write the JPAQuery, the retryCount variable does not have comparison operators like loe or goe. That column/variable only allows me to do a isNull, isNotNull, eq, and other very simple operators, but no comparison operators. This would look like below, however, obviously not execute the comparison I want, but it works without error:
JPAQuery query = new JPAQuery(entityManager);query.from(command).where(command.retryCount.isNotNull()).list(command);
In looking around I saw there is a way to create a NumberPath, which seems to be what I want, however, when I attempt the below code I get an exception "java.lang.IllegalArgumentException: Undeclared path 'retryCount'. Add this path as a source to the query to be able to reference it."
JPAQuery query = new JPAQuery(entityManager);NumberPath<Integer> retryCount = new NumberPath<Integer>(Integer.class, "retryCount");return query.from(command).where(retryCount.loe(10)).list(command);
So, how can I "add" this path to the source. I have looked around and I cannot find an example that does this nor an explanation as to how this is supposed to be done. The javadocs are not very helpful in this situation. I had been moving along nicely with querydsl, but this is the first roadblock and I'm stumped on writing one of the most simple queries. Any assistance or advice would be greatly appreciated.