diff --git a/example-sql-annotation/src/main/java/example/sql/annotation/EmployeeDao.java b/example-sql-annotation/src/main/java/example/sql/annotation/EmployeeDao.java index 33c69e7c..70fd1b54 100644 --- a/example-sql-annotation/src/main/java/example/sql/annotation/EmployeeDao.java +++ b/example-sql-annotation/src/main/java/example/sql/annotation/EmployeeDao.java @@ -25,229 +25,229 @@ public interface EmployeeDao { @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE id = /* id */0 - """) + SELECT /*%expand*/* + FROM employee + WHERE id = /* id */0 + """) @Select Employee selectById(Integer id); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE - /*%if min != null */ - age >= /* min */10 - /*%end */ - /*%if max != null */ - AND age <= /* max */70 - /*%end */ - ORDER BY age - """) + SELECT /*%expand*/* + FROM employee + WHERE + /*%if min != null */ + age >= /* min */10 + /*%end */ + /*%if max != null */ + AND age <= /* max */70 + /*%end */ + ORDER BY age + """) @Select List selectByAgeRange(Age min, Age max); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE - /*%for age : ages */ - age = /* age */30 - /*%if age_has_next */ - /*# "or" */ - /*%end */ - /*%end */ - """) + SELECT /*%expand*/* + FROM employee + WHERE + /*%for age : ages */ + age = /* age */30 + /*%if age_has_next */ + /*# "or" */ + /*%end */ + /*%end */ + """) @Select List selectByAges(List ages); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE - /*%if name != null*/ - name = /* name */'hoge' - /*%else */ - AND name IS NULL - /*%end */ - """) + SELECT /*%expand*/* + FROM employee + WHERE + /*%if name != null*/ + name = /* name */'hoge' + /*%else */ + AND name IS NULL + /*%end */ + """) @Select List selectByName(String name); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE name IN /* names */('aaa', 'bbb') - """) + SELECT /*%expand*/* + FROM employee + WHERE name IN /* names */('aaa', 'bbb') + """) @Select List selectByNames(List names); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE - /*%if @isNotEmpty(name) */ - name = /* name */'hoge' - /*%end*/ - """) + SELECT /*%expand*/* + FROM employee + WHERE + /*%if @isNotEmpty(name) */ + name = /* name */'hoge' + /*%end*/ + """) @Select List selectByNotEmptyName(String name); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE name LIKE /* @prefix(prefix) */'X%' escape '$' - """) + SELECT /*%expand*/* + FROM employee + WHERE name LIKE /* @prefix(prefix) */'X%' escape '$' + """) @Select List selectByNameWithPrefixMatching(String prefix); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE name LIKE /* @suffix(suffix) */'%X' escape '$' - """) + SELECT /*%expand*/* + FROM employee + WHERE name LIKE /* @suffix(suffix) */'%X' escape '$' + """) @Select List selectByNameWithSuffixMatching(String suffix); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE name LIKE /* @infix(inside) */'%X%' escape '$' - """) + SELECT /*%expand*/* + FROM employee + WHERE name LIKE /* @infix(inside) */'%X%' escape '$' + """) @Select List selectByNameWithInfixMatching(String inside); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE hiredate >= /* @roundDownTimePart(from) */'2001-01-01 12:34:56' - AND hiredate < /* @roundUpTimePart(to) */'2001-01-01 12:34:56' - """) + SELECT /*%expand*/* + FROM employee + WHERE hiredate >= /* @roundDownTimePart(from) */'2001-01-01 12:34:56' + AND hiredate < /* @roundUpTimePart(to) */'2001-01-01 12:34:56' + """) @Select List selectByHiredateRange(Timestamp from, Timestamp to); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE salary > /* salary */0 - """) + SELECT /*%expand*/* + FROM employee + WHERE salary > /* salary */0 + """) @Select List selectBySalary(Salary salary); @Sql( """ - SELECT sum(salary) - FROM employee - """) + SELECT sum(salary) + FROM employee + """) @Select Salary selectSummedSalary(); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE name = /* e.name */'aaa' - """) + SELECT /*%expand*/* + FROM employee + WHERE name = /* e.name */'aaa' + """) @Select List selectByExample(Employee e); @Sql( """ - SELECT /*%expand*/* - FROM employee - ORDER BY id - """) + SELECT /*%expand*/* + FROM employee + ORDER BY id + """) @Select List selectAll(); @Sql( """ - SELECT /*%expand*/* - FROM employee - ORDER BY id - """) + SELECT /*%expand*/* + FROM employee + ORDER BY id + """) @Select List selectAll(SelectOptions options); @Sql( """ - SELECT /*%expand*/* - FROM employee - WHERE age > /* age */0 - ORDER BY age - """) + SELECT /*%expand*/* + FROM employee + WHERE age > /* age */0 + ORDER BY age + """) @Select(strategy = SelectType.STREAM) R selectByAge(int age, Function, R> mapper); @Sql( """ - SELECT /*%expand */* - FROM employee e - LEFT OUTER JOIN department d - ON e.department_id = d.id - ORDER BY e.id - """) + SELECT /*%expand */* + FROM employee e + LEFT OUTER JOIN department d + ON e.department_id = d.id + ORDER BY e.id + """) @Select(aggregateStrategy = EmployeeAggregateStrategy.class) List selectAllEmployeeDepartment(); @Sql( """ - INSERT INTO Employee - (ID - , NAME - , AGE - , DEPARTMENT_ID - , HIREDATE - , JOB_TYPE - , SALARY - , INSERT_TIMESTAMP - , UPDATE_TIMESTAMP - , VERSION) - VALUES ( /* employee.id */1 - , /* employee.name */'test' - , /* employee.age */10 - , /* employee.departmentId */1 - , /* employee.hiredate */'2010-01-01' - , /* employee.jobType */'SALESMAN' - , /* employee.salary */300 - , /* employee.insertTimestamp */'2010-01-01 12:34:56' - , /* employee.updateTimestamp */'2010-01-01 12:34:56' - , /* employee.version */1 ) - """) + INSERT INTO Employee + (ID + , NAME + , AGE + , DEPARTMENT_ID + , HIREDATE + , JOB_TYPE + , SALARY + , INSERT_TIMESTAMP + , UPDATE_TIMESTAMP + , VERSION) + VALUES ( /* employee.id */1 + , /* employee.name */'test' + , /* employee.age */10 + , /* employee.departmentId */1 + , /* employee.hiredate */'2010-01-01' + , /* employee.jobType */'SALESMAN' + , /* employee.salary */300 + , /* employee.insertTimestamp */'2010-01-01 12:34:56' + , /* employee.updateTimestamp */'2010-01-01 12:34:56' + , /* employee.version */1 ) + """) @Insert int insert(Employee employee); @Sql( """ - UPDATE Employee - SET NAME = /* employee.name */'test' - , AGE = /* employee.age */10 - , DEPARTMENT_ID = /* employee.departmentId */1 - , HIREDATE = /* employee.hiredate */'2010-01-01' - , JOB_TYPE = /* employee.jobType */'SALESMAN' - , SALARY = /* employee.salary */300 - , UPDATE_TIMESTAMP = /* employee.updateTimestamp */'2010-01-01 12:34:56' - , VERSION = /* employee.version */1 - WHERE ID = /* employee.id */1 - """) + UPDATE Employee + SET NAME = /* employee.name */'test' + , AGE = /* employee.age */10 + , DEPARTMENT_ID = /* employee.departmentId */1 + , HIREDATE = /* employee.hiredate */'2010-01-01' + , JOB_TYPE = /* employee.jobType */'SALESMAN' + , SALARY = /* employee.salary */300 + , UPDATE_TIMESTAMP = /* employee.updateTimestamp */'2010-01-01 12:34:56' + , VERSION = /* employee.version */1 + WHERE ID = /* employee.id */1 + """) @Update int update(Employee employee); @Sql( """ - DELETE FROM Employee - WHERE ID = /* employee.id */0 - """) + DELETE FROM Employee + WHERE ID = /* employee.id */0 + """) @Delete int delete(Employee employee); }