Create SQL query from HTTP GET parameters

We have a Java web application with backend hibernation that provides REST resources. Now we are faced with the task of performing a general search, which is controlled by the request parameters in our request for receipt:

some/rest/resource?name_like=foo&created_on>=2012-09-12&sort_by_asc=something

or similar.

  • We do not want to predetermine all possible parameters (name, created_on, then)
  • We do not want to parse a String request to get control characters (e.g.> =)
  • and we don’t want to implement our own grammar to reflect things like _eq _like _goe, etc. (as an alternative or addition to control characters).

Is there some kind of infrastructure that provides assistance with this mapping of GET request parameters to a database request ?

Since we know what REST resource we get, we have an entity / table (select). It will probably also be necessary to predefine the COMPOUNDS to be performed in order to limit the depth of the search.

But besides this, we want the REST client-client to be able to perform any search without having to predetermine how a certain parameter and a certain control sequence will be translated into a search.


Now I'm trying to create a semi-automatic solution on Mysemas QueryDSL. This allows me to predefine sorting columns and columns, and I'm working on a simple string comparison to find options like "_like", "_loe", ... in a parameter, and then activate the corresponding predefined part of the search. Not much different from SQL String, except that SQL injection confirms the persistence of the type.

, " "??? ". , REST . , , . REST , .


, , - . , . Redmine, , REST, . facebook API. , , . .

, Hibernate, SQL HQL- -, , QueryDsl. ( SQL-)

? ? ?

+5
1

.NET, , , WCF.

uri-, - OData. 4.5 Filter Query Option. , .NET, , Java.

+1

All Articles