devonfw / devon4j

devonfw Java stack - create enterprise-grade business apps in Java safe and fast
Apache License 2.0
83 stars 87 forks source link

QueryHelper: Dynamic operator support for Comparable types #579

Closed smangel-cg closed 1 year ago

smangel-cg commented 1 year ago

As an application developer using devon4j as the backend stack, I want to use QueryHelper functionality similar to whereString for other datatypes so that I can build a filtering API that can dynamically handle filtering operators for datatypes other than String.

As of now, the QueryHelper in the jpa-basic module only supports handling dynamic operators for the String type, using the whereString method. However, I have found that such a helper function would be beneficial for other datatypes as well - especially for any Comparable type.

Simple example scenario: My API provides a route giving access to a certain ETO, which contains a date attribute. API users should be able to filter by this date attribute with operators other than ==. Normally, I would now need to write a piece of code for each attribute, deciding which QueryDSL expression to use. Because this is such a generic task, duplicated code can be avoided by providing a helper function for Comparable types within the QueryHelper of the jpa-basic module.

NOTE: I am currently working on a PR for this issue after discussing it with @SchettlerKoehler and @maybeec.