Skip to content

Advanced Querydsl Filtering #2962

@lowcasz

Description

@lowcasz

Querydsl is actually the best option in spring to get fully pageable and filtered rest endpoint. Combined with spring-data-rest it looks great.
But there is a game changer when we need little more advanced filtering e.g. "greaterThan", "greaterEqual", "contains", "startWith", etc.
In this situation generally spring-data-rest is not useful, we have to manually extend responses and controllers.
Extending predicate in controller looks very bad in MVC, DDD pattern.
Creating totally new predicate adding manually all equal conditions gives a headache.

My proposition is to add additional REST filter parameters for every Entity field e.g.:
&fieldNameGreaterThan=
&fieldNameGreaterEqual=
&fieldNameContains= a,b,c //for arrays/collections (optional mapping, standard should be ?fContains=x&fContains=y)
&fieldNameContains= someStringPart //for strings
&fieldNameStartWith= (optionally separated by comma)
&fieldNameNot= (optionally separated by comma)

It will resolve filtering problem in most used applications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    has: design-decisionAn issue that contains a design decision about its topicstatus: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions