Skip to content

Commit 4d489ac

Browse files
authored
Merge pull request #376 from xterao/chore/sql-annotation-format
Reformatting SQL in DAO Methods Using the Sql Annotation
2 parents 3e744db + d48d40e commit 4d489ac

File tree

1 file changed

+128
-128
lines changed

1 file changed

+128
-128
lines changed

example-sql-annotation/src/main/java/example/sql/annotation/EmployeeDao.java

Lines changed: 128 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -25,229 +25,229 @@ public interface EmployeeDao {
2525

2626
@Sql(
2727
"""
28-
SELECT /*%expand*/*
29-
FROM employee
30-
WHERE id = /* id */0
31-
""")
28+
SELECT /*%expand*/*
29+
FROM employee
30+
WHERE id = /* id */0
31+
""")
3232
@Select
3333
Employee selectById(Integer id);
3434

3535
@Sql(
3636
"""
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-
""")
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+
""")
4848
@Select
4949
List<Employee> selectByAgeRange(Age min, Age max);
5050

5151
@Sql(
5252
"""
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-
""")
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+
""")
6363
@Select
6464
List<Employee> selectByAges(List<Age> ages);
6565

6666
@Sql(
6767
"""
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-
""")
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+
""")
7777
@Select
7878
List<Employee> selectByName(String name);
7979

8080
@Sql(
8181
"""
82-
SELECT /*%expand*/*
83-
FROM employee
84-
WHERE name IN /* names */('aaa', 'bbb')
85-
""")
82+
SELECT /*%expand*/*
83+
FROM employee
84+
WHERE name IN /* names */('aaa', 'bbb')
85+
""")
8686
@Select
8787
List<Employee> selectByNames(List<String> names);
8888

8989
@Sql(
9090
"""
91-
SELECT /*%expand*/*
92-
FROM employee
93-
WHERE
94-
/*%if @isNotEmpty(name) */
95-
name = /* name */'hoge'
96-
/*%end*/
97-
""")
91+
SELECT /*%expand*/*
92+
FROM employee
93+
WHERE
94+
/*%if @isNotEmpty(name) */
95+
name = /* name */'hoge'
96+
/*%end*/
97+
""")
9898
@Select
9999
List<Employee> selectByNotEmptyName(String name);
100100

101101
@Sql(
102102
"""
103-
SELECT /*%expand*/*
104-
FROM employee
105-
WHERE name LIKE /* @prefix(prefix) */'X%' escape '$'
106-
""")
103+
SELECT /*%expand*/*
104+
FROM employee
105+
WHERE name LIKE /* @prefix(prefix) */'X%' escape '$'
106+
""")
107107
@Select
108108
List<Employee> selectByNameWithPrefixMatching(String prefix);
109109

110110
@Sql(
111111
"""
112-
SELECT /*%expand*/*
113-
FROM employee
114-
WHERE name LIKE /* @suffix(suffix) */'%X' escape '$'
115-
""")
112+
SELECT /*%expand*/*
113+
FROM employee
114+
WHERE name LIKE /* @suffix(suffix) */'%X' escape '$'
115+
""")
116116
@Select
117117
List<Employee> selectByNameWithSuffixMatching(String suffix);
118118

119119
@Sql(
120120
"""
121-
SELECT /*%expand*/*
122-
FROM employee
123-
WHERE name LIKE /* @infix(inside) */'%X%' escape '$'
124-
""")
121+
SELECT /*%expand*/*
122+
FROM employee
123+
WHERE name LIKE /* @infix(inside) */'%X%' escape '$'
124+
""")
125125
@Select
126126
List<Employee> selectByNameWithInfixMatching(String inside);
127127

128128
@Sql(
129129
"""
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-
""")
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+
""")
135135
@Select
136136
List<Employee> selectByHiredateRange(Timestamp from, Timestamp to);
137137

138138
@Sql(
139139
"""
140-
SELECT /*%expand*/*
141-
FROM employee
142-
WHERE salary > /* salary */0
143-
""")
140+
SELECT /*%expand*/*
141+
FROM employee
142+
WHERE salary > /* salary */0
143+
""")
144144
@Select
145145
List<Employee> selectBySalary(Salary salary);
146146

147147
@Sql(
148148
"""
149-
SELECT sum(salary)
150-
FROM employee
151-
""")
149+
SELECT sum(salary)
150+
FROM employee
151+
""")
152152
@Select
153153
Salary selectSummedSalary();
154154

155155
@Sql(
156156
"""
157-
SELECT /*%expand*/*
158-
FROM employee
159-
WHERE name = /* e.name */'aaa'
160-
""")
157+
SELECT /*%expand*/*
158+
FROM employee
159+
WHERE name = /* e.name */'aaa'
160+
""")
161161
@Select
162162
List<Employee> selectByExample(Employee e);
163163

164164
@Sql(
165165
"""
166-
SELECT /*%expand*/*
167-
FROM employee
168-
ORDER BY id
169-
""")
166+
SELECT /*%expand*/*
167+
FROM employee
168+
ORDER BY id
169+
""")
170170
@Select
171171
List<Employee> selectAll();
172172

173173
@Sql(
174174
"""
175-
SELECT /*%expand*/*
176-
FROM employee
177-
ORDER BY id
178-
""")
175+
SELECT /*%expand*/*
176+
FROM employee
177+
ORDER BY id
178+
""")
179179
@Select
180180
List<Employee> selectAll(SelectOptions options);
181181

182182
@Sql(
183183
"""
184-
SELECT /*%expand*/*
185-
FROM employee
186-
WHERE age > /* age */0
187-
ORDER BY age
188-
""")
184+
SELECT /*%expand*/*
185+
FROM employee
186+
WHERE age > /* age */0
187+
ORDER BY age
188+
""")
189189
@Select(strategy = SelectType.STREAM)
190190
<R> R selectByAge(int age, Function<Stream<Employee>, R> mapper);
191191

192192
@Sql(
193193
"""
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-
""")
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+
""")
200200
@Select(aggregateStrategy = EmployeeAggregateStrategy.class)
201201
List<Employee> selectAllEmployeeDepartment();
202202

203203
@Sql(
204204
"""
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-
""")
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+
""")
227227
@Insert
228228
int insert(Employee employee);
229229

230230
@Sql(
231231
"""
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-
""")
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+
""")
243243
@Update
244244
int update(Employee employee);
245245

246246
@Sql(
247247
"""
248-
DELETE FROM Employee
249-
WHERE ID = /* employee.id */0
250-
""")
248+
DELETE FROM Employee
249+
WHERE ID = /* employee.id */0
250+
""")
251251
@Delete
252252
int delete(Employee employee);
253253
}

0 commit comments

Comments
 (0)