Skip to content

Commit 2aa75ec

Browse files
committed
Small improvements.
1 parent 5540a93 commit 2aa75ec

File tree

1 file changed

+55
-73
lines changed

1 file changed

+55
-73
lines changed

README.md

Lines changed: 55 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -8,102 +8,84 @@ Supports horizontal database sharding (partition/access logic lies within applic
88
Type Mapping
99
------------
1010

11-
The SprocWrapper provides and efficient and easy-to-use mechanimism for translatiing values from database to Java objects and vice-versa. It allows us to map not only primitive types, but also complex types (Java domain objects).
11+
The SprocWrapper provides and efficient and easy-to-use mechanimism for translating values from database to Java objects and vice-versa. It allows us to map not only primitive types, but also complex types (Java domain objects).
1212

13-
Here are some examples.
13+
Here are some examples!
1414

15-
Basic type:
15+
Using a basic types:
1616

1717
```java
18-
@SProcCall
19-
String getNameForId(@SProcParam int id);
18+
@SProcService
19+
public interface CustomerSProcService {
20+
@SProcCall
21+
int registerCustomer(@SProcParam String name, @SProcParam String email);
22+
}
2023
```
2124

2225
```sql
23-
CREATE FUNCTION get_name_for_id(p_id int) RETURNS text AS
26+
CREATE FUNCTION register_customer(p_name text, p_email text)
27+
RETURNS int AS
2428
$$
25-
SELECT name
26-
FROM customer
27-
WHERE id = p_id
28-
$$ LANGUAGE ‘sql’;
29+
INSERT INTO z_data.customer(c_email, c_gender)
30+
VALUES (p_email, p_gender)
31+
RETURNING c_id
32+
$$
33+
LANGUAGE 'sql' SECURITY DEFINER;
2934
```
3035

31-
Complex type:
36+
And a complex type:
3237

3338
```java
34-
@SProcCall
35-
List<Order> findOrders(@SProcParam String email);
39+
@SProcService
40+
public interface OrderSProcService {
41+
@SProcCall
42+
List<Order> findOrders(@SProcParam String email);
43+
}
3644
```
3745

3846
```sql
3947
CREATE FUNCTION find_orders(p_email text,
4048
OUT order_id int,
4149
OUT order_date timestamp,
42-
OUT shipping_address order_address) RETURNS SETOF RECORD AS
50+
OUT shipping_address order_address)
51+
RETURNS SETOF RECORD AS
4352
$$
44-
SELECT o_id,
45-
o_date,
46-
ROW(oa_street, oa_city, oa_country)::order_address
47-
FROM z_data.order
48-
JOIN z_data.order_address
49-
ON oa_order_id = o_id
50-
JOIN z_data.customer
51-
ON c_id = o_customer_id
52-
WHERE c_email = p_email
53+
SELECT o_id,
54+
o_date,
55+
ROW(oa_street, oa_city, oa_country)::order_address
56+
FROM z_data.order
57+
JOIN z_data.order_address
58+
ON oa_order_id = o_id
59+
JOIN z_data.customer
60+
ON c_id = o_customer_id
61+
WHERE c_email = p_email
5362
$$
5463
LANGUAGE 'sql' SECURITY DEFINER;
5564
```
5665

57-
Supported data types:
58-
59-
Numeric Types:
60-
61-
| Database | JAVA |
62-
| ---------------- | -------------------- |
63-
| smallint | int |
64-
| integer | int |
65-
| bigint | long |
66-
| decimal | java.math.BigDecimal |
67-
| numeric | java.math.BigDecimal |
68-
| real | float |
69-
| double precision | double |
70-
| serial | int |
71-
| bigserial | long |
72-
73-
Character Types:
74-
75-
| Database | JAVA |
76-
| ---------------- | -------------------- |
77-
| varchar | String |
78-
| char | char |
79-
| text | String |
80-
81-
Date/Time Types:
82-
83-
| Database | JAVA |
84-
| ---------------- | -------------------- |
85-
| timestamp | java.sql.Timestamp |
86-
| date | java.sql.Timestamp |
87-
| time | java.sql.Timestamp |
88-
89-
Boolean Type:
90-
91-
| Database | JAVA |
92-
| ---------------- | -------------------- |
93-
| boolean | boolean |
94-
95-
Enumerated Types:
96-
97-
| Database | JAVA |
98-
| ---------------- | -------------------- |
99-
| enum | java.lang.Enum |
100-
101-
Container types:
102-
103-
| Database | JAVA |
104-
| ---------------- | ----------------------------- |
105-
| array | java.util.List/java.util.Set |
106-
| hstore | java.util.Map<String, String> |
66+
SprocWrapper supports the following data types:
67+
68+
| Database | Java |
69+
| ---------------- | ------------------------------------------------- |
70+
| smallint | int |
71+
| integer | int |
72+
| bigint | long |
73+
| decimal | java.math.BigDecimal |
74+
| numeric | java.math.BigDecimal |
75+
| real | float |
76+
| double precision | double |
77+
| serial | int |
78+
| bigserial | long |
79+
| varchar | java.lang.String |
80+
| char | char |
81+
| text | java.lang.String |
82+
| timestamp | java.sql.Timestamp |
83+
| date | java.sql.Timestamp |
84+
| time | java.sql.Timestamp |
85+
| boolean | boolean |
86+
| enum | java.lang.Enum |
87+
| array | java.util.List/java.util.Set |
88+
| hstore | java.util.Map<java.lang.String, java.lang.String> |
10789

10890

10991
Note: Sprocwrapper doesn't support functions returning arrays as a single output. If one wants to return a collection, please return a SETOF instead.

0 commit comments

Comments
 (0)