You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HTTP-RPC is an open-source framework for implementing and interacting with RESTful and REST-like web services in Java. It is extremely lightweight and requires only a Java runtime environment and a servlet container. The entire framework is distributed as a single JAR file that is about 65KB in size, making it an ideal choice for applications where a minimal footprint is desired.
5
+
HTTP-RPC is an open-source framework for implementing and interacting with RESTful and REST-like web services in Java. It is extremely lightweight and requires only a Java runtime environment and a servlet container. The entire framework is distributed as a single JAR file that is about 66KB in size, making it an ideal choice for applications where a minimal footprint is desired.
6
6
7
7
This guide introduces the HTTP-RPC framework and provides an overview of its key features.
8
8
@@ -13,6 +13,12 @@ Feedback is welcome and encouraged. Please feel free to [contact me](mailto:gk_b
13
13
*[Getting HTTP-RPC](#getting-http-rpc)
14
14
*[HTTP-RPC Classes](#http-rpc-classes)
15
15
*[WebService](#webservice)
16
+
* [Method Arguments](#method-arguments)
17
+
* [Return Values](#return-values)
18
+
* [Exceptions](#exceptions)
19
+
* [Request and Repsonse Properties](#request-and-repsonse-properties)
20
+
* [Path Variables](#path-variables)
21
+
* [Documentation](#documentation)
16
22
*[JSONEncoder and JSONDecoder](#jsonencoder-and-jsondecoder)
17
23
*[CSVEncoder and CSVDecoder](#csvencoder-and-csvdecoder)
18
24
*[BeanAdapter](#beanadapter)
@@ -702,7 +708,7 @@ Once applied, the statement can be executed:
702
708
return new ResultSetAdapter(statement.executeQuery());
703
709
```
704
710
705
-
A complete example that uses both classes is shown below. It is based on the "pet" table from the MySQL sample database:
711
+
A complete example that uses both classes is shown below. It is based on the "pet" table from the MySQL "menagerie" sample database:
706
712
707
713
```sql
708
714
CREATE TABLE pet (
@@ -792,7 +798,99 @@ the values of the "first_name" and "last_name" columns would be returned in a ne
792
798
]
793
799
```
794
800
795
-
TODONested queries
801
+
### NestedQueries
802
+
`ResultSetAdapter` can also be used to return the results of nested queries. The `attach()` method assigns a subquery to a key in the result map:
Each attached query is executed once per row in the result set. The resulting rows are returned in a list that is associated with the corresponding key.
809
+
810
+
Internally, subqueries are executed as prepared statements using the `Parameters` class. All values in the base row are supplied as parameter values to each subquery.
811
+
812
+
An example based on the MySQL"employees" sample database is shown below. The base query retreives the employee's number, first name, and last name from the "employees" table. Subqueries to return the employee's salary and title history are optionally attached based on the values provided in the `details` parameter:
A sample response including both titles and salaries is shown below:
870
+
871
+
```json
872
+
{
873
+
"employeeNumber":10004,
874
+
"firstName":"Chirstian",
875
+
"lastName":"Koblick",
876
+
"titles": [
877
+
{
878
+
"title":"Senior Engineer",
879
+
"fromDate":817794000000,
880
+
"toDate":253370782800000
881
+
},
882
+
...
883
+
],
884
+
"salaries": [
885
+
{
886
+
"salary":74057,
887
+
"fromDate":1006837200000,
888
+
"toDate":253370782800000
889
+
},
890
+
...
891
+
]
892
+
}
893
+
```
796
894
797
895
### TypedIteration
798
896
The `adapt()` method of the `ResultSetAdapter` classcan be used to facilitate typed iteration of query results. This method produces an `Iterable` sequence of values of a given interfacetype representing the rows in the result set. The returned adapter uses dynamic proxy invocation to map properties declared by the interfaceto column labels in the result set. A single proxy instance is used for all rows to minimize heap allocation.
0 commit comments