-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathresult.txt
203 lines (185 loc) · 4.37 KB
/
result.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
CREATE TYPE Parent AS (
id integer,
name text,
first_name text,
parent_data_id integer,
parent_data Parent_data
);
CREATE TYPE Parent_data AS (
id integer,
street text,
city text
);
@DatabaseType
class Parent {
@DatabaseField
private Integer id;
@DatabaseField
private String name;
@DatabaseField
private String firstName;
@DatabaseField
private Integer parentDataId;
@DatabaseField
private ParentData parentData;
public Integer getid() {
return id;
}
public void setid(Integer aInteger) {
id = aInteger;
}
public String getname() {
return name;
}
public void setname(String aString) {
name = aString;
}
public String getfirstName() {
return firstName;
}
public void setfirstName(String aString) {
firstName = aString;
}
public Integer getparentDataId() {
return parentDataId;
}
public void setparentDataId(Integer aInteger) {
parentDataId = aInteger;
}
public ParentData getparentData() {
return parentData;
}
public void setparentData(ParentData aParentData) {
parentData = aParentData;
}
}
@DatabaseType
class ParentData {
@DatabaseField
private Integer id;
@DatabaseField
private String street;
@DatabaseField
private String city;
public Integer getid() {
return id;
}
public void setid(Integer aInteger) {
id = aInteger;
}
public String getstreet() {
return street;
}
public void setstreet(String aString) {
street = aString;
}
public String getcity() {
return city;
}
public void setcity(String aString) {
city = aString;
}
}
CREATE OR REPLACE FUNCTION insertPublicParent(p_in parentType) RETURNS SETOF parentType AS
$$
DECLARE
RETURN QUERY INSERT INTO public.parent (
p_name,
p_first_name,
p_parent_data_id
)
SELECT
p_in.name,
p_in.first_name,
p_in.parent_data_id
RETURNING
p_id,
p_name,
p_first_name,
p_parent_data_id
END;
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
CREATE OR REPLACE FUNCTION deletePublicParent(p_in parentType) RETURNS SETOF parentType AS
$$
DECLARE
BEGIN
RETURN DELETE FROM public.parent
WHERE
p_id = p_in.id
RETURNING
p_id,
p_name,
p_first_name,
p_parent_data_id
END;
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
CREATE OR REPLACE FUNCTION updatePublicParent(p_in parentType) RETURNS SETOF parentType AS
$$
DECLARE
BEGIN
RETURN QUERY UPDATE public.parent
SET
p_name = COALESCE ( p_in.name, p_name ),
p_first_name = COALESCE ( p_in.first_name, p_first_name ),
p_parent_data_id = COALESCE ( p_in.parent_data_id, p_parent_data_id )
WHERE
p_id = p_in.id
RETURNING
p_id,
p_name,
p_first_name,
p_parent_data_id
END;
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
CREATE OR REPLACE FUNCTION selectPublicParent(p_in parentType) RETURNS SETOF parentType AS
$$
DECLARE
BEGIN
RETURN QUERY SELECT
p_id,
p_name,
p_first_name,
p_parent_data_id,
CASE WHEN (p_parent_data_id) IS NOT NULL THEN
(SELECT pd_id,pd_street,pd_city
FROM public.parent_data
WHERE (p_parent_data_id) = (pd_id)) ELSE NULL END
WHERE
p_id = p_in.id
;
END;
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
None
import de.zalando.sprocwrapper.SProcCall;
import de.zalando.sprocwrapper.SProcParam;
import de.zalando.sprocwrapper.SProcService;
@SProcService
public interface ParentService {
public Parent insertParent( Parent aParent );
public Parent deleteParent( Parent aParent );
public Parent updateParent( Parent aParent );
public Parent selectPkParent( Parent aParent );
}
import org.springframework.stereotype.Repository;
import de.zalando.sprocwrapper.AbstractSProcService;
@Repository
public class ParentServiceImpl
extends AbstractSProcService<ParentService, BitMapDatasourceProvider>
implements ParentService {
@Autowired
public ParentServiceImpl( final BitMapDatasourceProvider p ) {
super(p, ParentService.class);
}
public Parent insertParent( Parent aParent ) {
return sproc.insertParent( aParent);
}
public Parent deleteParent( Parent aParent ) {
return sproc.deleteParent( aParent);
}
public Parent updateParent( Parent aParent ) {
return sproc.updateParent( aParent);
}
public Parent selectPkParent( Parent aParent ) {
return sproc.selectPkParent( aParent);
}
}