4
4
import example .common .domain .Salary ;
5
5
import example .common .entity .Department ;
6
6
import example .common .entity .Employee ;
7
+
7
8
import java .sql .Timestamp ;
8
9
import java .util .List ;
9
10
import java .util .function .BiFunction ;
10
11
import java .util .function .Function ;
11
12
import java .util .stream .Stream ;
13
+
12
14
import org .seasar .doma .AggregateStrategy ;
13
15
import org .seasar .doma .AssociationLinker ;
14
16
import org .seasar .doma .Dao ;
@@ -25,229 +27,229 @@ public interface EmployeeDao {
25
27
26
28
@ Sql (
27
29
"""
28
- SELECT /*%expand*/*
29
- FROM employee
30
- WHERE id = /* id */0
31
- """ )
30
+ SELECT /*%expand*/*
31
+ FROM employee
32
+ WHERE id = /* id */0
33
+ """ )
32
34
@ Select
33
35
Employee selectById (Integer id );
34
36
35
37
@ Sql (
36
38
"""
37
- SELECT /*%expand*/*
38
- FROM employee
39
- WHERE
40
- /*%if min != null */
41
- age >= /* min */10
42
- /*%end */
43
- /*%if max != null */
44
- AND age <= /* max */70
45
- /*%end */
46
- ORDER BY age
47
- """ )
39
+ SELECT /*%expand*/*
40
+ FROM employee
41
+ WHERE
42
+ /*%if min != null */
43
+ age >= /* min */10
44
+ /*%end */
45
+ /*%if max != null */
46
+ AND age <= /* max */70
47
+ /*%end */
48
+ ORDER BY age
49
+ """ )
48
50
@ Select
49
51
List <Employee > selectByAgeRange (Age min , Age max );
50
52
51
53
@ Sql (
52
54
"""
53
- SELECT /*%expand*/*
54
- FROM employee
55
- WHERE
56
- /*%for age : ages */
57
- age = /* age */30
58
- /*%if age_has_next */
59
- /*# "or" */
60
- /*%end */
61
- /*%end */
62
- """ )
55
+ SELECT /*%expand*/*
56
+ FROM employee
57
+ WHERE
58
+ /*%for age : ages */
59
+ age = /* age */30
60
+ /*%if age_has_next */
61
+ /*# "or" */
62
+ /*%end */
63
+ /*%end */
64
+ """ )
63
65
@ Select
64
66
List <Employee > selectByAges (List <Age > ages );
65
67
66
68
@ Sql (
67
69
"""
68
- SELECT /*%expand*/*
69
- FROM employee
70
- WHERE
71
- /*%if name != null*/
72
- name = /* name */'hoge'
73
- /*%else */
74
- AND name IS NULL
75
- /*%end */
76
- """ )
70
+ SELECT /*%expand*/*
71
+ FROM employee
72
+ WHERE
73
+ /*%if name != null*/
74
+ name = /* name */'hoge'
75
+ /*%else */
76
+ AND name IS NULL
77
+ /*%end */
78
+ """ )
77
79
@ Select
78
80
List <Employee > selectByName (String name );
79
81
80
82
@ Sql (
81
83
"""
82
- SELECT /*%expand*/*
83
- FROM employee
84
- WHERE name IN /* names */('aaa', 'bbb')
85
- """ )
84
+ SELECT /*%expand*/*
85
+ FROM employee
86
+ WHERE name IN /* names */('aaa', 'bbb')
87
+ """ )
86
88
@ Select
87
89
List <Employee > selectByNames (List <String > names );
88
90
89
91
@ Sql (
90
92
"""
91
- SELECT /*%expand*/*
92
- FROM employee
93
- WHERE
94
- /*%if @isNotEmpty(name) */
95
- name = /* name */'hoge'
96
- /*%end*/
97
- """ )
93
+ SELECT /*%expand*/*
94
+ FROM employee
95
+ WHERE
96
+ /*%if @isNotEmpty(name) */
97
+ name = /* name */'hoge'
98
+ /*%end*/
99
+ """ )
98
100
@ Select
99
101
List <Employee > selectByNotEmptyName (String name );
100
102
101
103
@ Sql (
102
104
"""
103
- SELECT /*%expand*/*
104
- FROM employee
105
- WHERE name LIKE /* @prefix(prefix) */'X%' escape '$'
106
- """ )
105
+ SELECT /*%expand*/*
106
+ FROM employee
107
+ WHERE name LIKE /* @prefix(prefix) */'X%' escape '$'
108
+ """ )
107
109
@ Select
108
110
List <Employee > selectByNameWithPrefixMatching (String prefix );
109
111
110
112
@ Sql (
111
113
"""
112
- SELECT /*%expand*/*
113
- FROM employee
114
- WHERE name LIKE /* @suffix(suffix) */'%X' escape '$'
115
- """ )
114
+ SELECT /*%expand*/*
115
+ FROM employee
116
+ WHERE name LIKE /* @suffix(suffix) */'%X' escape '$'
117
+ """ )
116
118
@ Select
117
119
List <Employee > selectByNameWithSuffixMatching (String suffix );
118
120
119
121
@ Sql (
120
122
"""
121
- SELECT /*%expand*/*
122
- FROM employee
123
- WHERE name LIKE /* @infix(inside) */'%X%' escape '$'
124
- """ )
123
+ SELECT /*%expand*/*
124
+ FROM employee
125
+ WHERE name LIKE /* @infix(inside) */'%X%' escape '$'
126
+ """ )
125
127
@ Select
126
128
List <Employee > selectByNameWithInfixMatching (String inside );
127
129
128
130
@ Sql (
129
131
"""
130
- SELECT /*%expand*/*
131
- FROM employee
132
- WHERE hiredate >= /* @roundDownTimePart(from) */'2001-01-01 12:34:56'
133
- AND hiredate < /* @roundUpTimePart(to) */'2001-01-01 12:34:56'
134
- """ )
132
+ SELECT /*%expand*/*
133
+ FROM employee
134
+ WHERE hiredate >= /* @roundDownTimePart(from) */'2001-01-01 12:34:56'
135
+ AND hiredate < /* @roundUpTimePart(to) */'2001-01-01 12:34:56'
136
+ """ )
135
137
@ Select
136
138
List <Employee > selectByHiredateRange (Timestamp from , Timestamp to );
137
139
138
140
@ Sql (
139
141
"""
140
- SELECT /*%expand*/*
141
- FROM employee
142
- WHERE salary > /* salary */0
143
- """ )
142
+ SELECT /*%expand*/*
143
+ FROM employee
144
+ WHERE salary > /* salary */0
145
+ """ )
144
146
@ Select
145
147
List <Employee > selectBySalary (Salary salary );
146
148
147
149
@ Sql (
148
150
"""
149
- SELECT sum(salary)
150
- FROM employee
151
- """ )
151
+ SELECT sum(salary)
152
+ FROM employee
153
+ """ )
152
154
@ Select
153
155
Salary selectSummedSalary ();
154
156
155
157
@ Sql (
156
158
"""
157
- SELECT /*%expand*/*
158
- FROM employee
159
- WHERE name = /* e.name */'aaa'
160
- """ )
159
+ SELECT /*%expand*/*
160
+ FROM employee
161
+ WHERE name = /* e.name */'aaa'
162
+ """ )
161
163
@ Select
162
164
List <Employee > selectByExample (Employee e );
163
165
164
166
@ Sql (
165
167
"""
166
- SELECT /*%expand*/*
167
- FROM employee
168
- ORDER BY id
169
- """ )
168
+ SELECT /*%expand*/*
169
+ FROM employee
170
+ ORDER BY id
171
+ """ )
170
172
@ Select
171
173
List <Employee > selectAll ();
172
174
173
175
@ Sql (
174
176
"""
175
- SELECT /*%expand*/*
176
- FROM employee
177
- ORDER BY id
178
- """ )
177
+ SELECT /*%expand*/*
178
+ FROM employee
179
+ ORDER BY id
180
+ """ )
179
181
@ Select
180
182
List <Employee > selectAll (SelectOptions options );
181
183
182
184
@ Sql (
183
185
"""
184
- SELECT /*%expand*/*
185
- FROM employee
186
- WHERE age > /* age */0
187
- ORDER BY age
188
- """ )
186
+ SELECT /*%expand*/*
187
+ FROM employee
188
+ WHERE age > /* age */0
189
+ ORDER BY age
190
+ """ )
189
191
@ Select (strategy = SelectType .STREAM )
190
192
<R > R selectByAge (int age , Function <Stream <Employee >, R > mapper );
191
193
192
194
@ Sql (
193
195
"""
194
- SELECT /*%expand */*
195
- FROM employee e
196
- LEFT OUTER JOIN department d
197
- ON e.department_id = d.id
198
- ORDER BY e.id
199
- """ )
196
+ SELECT /*%expand */*
197
+ FROM employee e
198
+ LEFT OUTER JOIN department d
199
+ ON e.department_id = d.id
200
+ ORDER BY e.id
201
+ """ )
200
202
@ Select (aggregateStrategy = EmployeeAggregateStrategy .class )
201
203
List <Employee > selectAllEmployeeDepartment ();
202
204
203
205
@ Sql (
204
206
"""
205
- INSERT INTO Employee
206
- (ID
207
- , NAME
208
- , AGE
209
- , DEPARTMENT_ID
210
- , HIREDATE
211
- , JOB_TYPE
212
- , SALARY
213
- , INSERT_TIMESTAMP
214
- , UPDATE_TIMESTAMP
215
- , VERSION)
216
- VALUES ( /* employee.id */1
217
- , /* employee.name */'test'
218
- , /* employee.age */10
219
- , /* employee.departmentId */1
220
- , /* employee.hiredate */'2010-01-01'
221
- , /* employee.jobType */'SALESMAN'
222
- , /* employee.salary */300
223
- , /* employee.insertTimestamp */'2010-01-01 12:34:56'
224
- , /* employee.updateTimestamp */'2010-01-01 12:34:56'
225
- , /* employee.version */1 )
226
- """ )
207
+ INSERT INTO Employee
208
+ (ID
209
+ , NAME
210
+ , AGE
211
+ , DEPARTMENT_ID
212
+ , HIREDATE
213
+ , JOB_TYPE
214
+ , SALARY
215
+ , INSERT_TIMESTAMP
216
+ , UPDATE_TIMESTAMP
217
+ , VERSION)
218
+ VALUES ( /* employee.id */1
219
+ , /* employee.name */'test'
220
+ , /* employee.age */10
221
+ , /* employee.departmentId */1
222
+ , /* employee.hiredate */'2010-01-01'
223
+ , /* employee.jobType */'SALESMAN'
224
+ , /* employee.salary */300
225
+ , /* employee.insertTimestamp */'2010-01-01 12:34:56'
226
+ , /* employee.updateTimestamp */'2010-01-01 12:34:56'
227
+ , /* employee.version */1 )
228
+ """ )
227
229
@ Insert
228
230
int insert (Employee employee );
229
231
230
232
@ Sql (
231
233
"""
232
- UPDATE Employee
233
- SET NAME = /* employee.name */'test'
234
- , AGE = /* employee.age */10
235
- , DEPARTMENT_ID = /* employee.departmentId */1
236
- , HIREDATE = /* employee.hiredate */'2010-01-01'
237
- , JOB_TYPE = /* employee.jobType */'SALESMAN'
238
- , SALARY = /* employee.salary */300
239
- , UPDATE_TIMESTAMP = /* employee.updateTimestamp */'2010-01-01 12:34:56'
240
- , VERSION = /* employee.version */1
241
- WHERE ID = /* employee.id */1
242
- """ )
234
+ UPDATE Employee
235
+ SET NAME = /* employee.name */'test'
236
+ , AGE = /* employee.age */10
237
+ , DEPARTMENT_ID = /* employee.departmentId */1
238
+ , HIREDATE = /* employee.hiredate */'2010-01-01'
239
+ , JOB_TYPE = /* employee.jobType */'SALESMAN'
240
+ , SALARY = /* employee.salary */300
241
+ , UPDATE_TIMESTAMP = /* employee.updateTimestamp */'2010-01-01 12:34:56'
242
+ , VERSION = /* employee.version */1
243
+ WHERE ID = /* employee.id */1
244
+ """ )
243
245
@ Update
244
246
int update (Employee employee );
245
247
246
248
@ Sql (
247
249
"""
248
- DELETE FROM Employee
249
- WHERE ID = /* employee.id */0
250
- """ )
250
+ DELETE FROM Employee
251
+ WHERE ID = /* employee.id */0
252
+ """ )
251
253
@ Delete
252
254
int delete (Employee employee );
253
255
}
0 commit comments