Ad

How To Handle The "ALL" Using SQL Query Inside SPRING REST API?

- 1 answer

I'am building REST API to work with Android application. Android app has dropdowns (spinners) and datepickers allowing to choose parameters. Request are processed and changed to SQL (Oracle 11g) querys using @Query (...) annotation.

Problem starts when I want to hendle 'ALL' option (take all options).

REST API is JAVA Spring Boot and Hibernate. Android app sends request with parameters and response is plain JSON. If user selects 'ALL' param value is 999999 (it may be changed if needed).

So it looks like: myurl/getinfo/2/4/999999/56

I tryied many options: ?1 to send all conditions, used % as param value, writen methods to build native query as String and send using PreparedStatement. Nothing works. Always errors.

Can someone enlighten me as it should generally look like? How to handle 'ALL' send as parameter and how to process it by Java Spring REST?

Thanks in advance :-)

Ad

Answer

May be Criteria Api is better for this- you will get program way to manage restriction (where clause in sql). look to turorial: https://www.tutorialspoint.com/hibernate/hibernate_criteria_queries.htm

Ad
source: stackoverflow.com
Ad