I have request like this:
http://localhost:4000/services/querywithdsl?min=30&max=90
My domain entity only consists of id :
@Entity
@Data
public class ServiceNumberPorting {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(updatable = false, nullable = false)
private Long id;
}
And my rest controller with predicate
@GetMapping(value = "/services/querywithdsl")
public ResponseEntity<List<ServiceNumberPortingMapper>>getServiceNumberPortingWithDsl(@QuerydslPredicate(root = ServiceNumberPorting.class) Predicate predicate) {
...
}
Repository:
public interface ServiceNumberPortingRepository extends JpaRepository<ServiceNumberPorting, Long>,QuerydslPredicateExecutor<ServiceNumberPorting>, QuerydslBinderCustomizer<QServiceNumberPorting>
I want to build query with querydsl like this one using bindings
..where id>min and id< max
All examples I found are directly mapping query parameters to entity column, but in this example, I have only id in my entity and I want to do range check with incoming parameter values which have different name than my entity columns.
However, since my domain won't consist of min and max columns I could't get it working with customizing binding such as using QueryDslBinderCustomizer:
bindings.bind(store.city).single((path, value) -> path.endsWith(value));
How to accomplish that?
Here is docs that I gone through: spring data examples binding examples