├── .classpath
├── .gitignore
├── .project
├── .settings
├── .gitignore
├── org.eclipse.jdt.core.prefs
└── org.eclipse.m2e.core.prefs
├── CHANGES.md
├── LICENSE.txt
├── README.md
├── abacus-eclipse-formatter.xml
├── docs
├── CSVUtil.gif
├── CSVUtil_view.html
├── CallableQuery.gif
├── CallableQuery_view.html
├── Columns.gif
├── Columns_view.html
├── ConditionFactory.gif
├── ConditionFactory_view.html
├── CrudDao.gif
├── CrudDao_view.html
├── Dao.gif
├── Dao_view.html
├── DataSet.gif
├── DataSet_view.html
├── DynamicSQLBuilder.gif
├── DynamicSQLBuilder_view.html
├── Jdbc.gif
├── JdbcContext.gif
├── JdbcContext_view.html
├── JdbcUtil.gif
├── JdbcUtil_view.html
├── JdbcUtils.gif
├── JdbcUtils_view.html
├── Jdbc_view.html
├── JoinEntityHelper.gif
├── JoinEntityHelper_view.html
├── Mapper.gif
├── Mapper_view.html
├── NamedQuery.gif
├── NamedQuery_view.html
├── PreparedQuery.gif
├── PreparedQuery_view.html
├── SQLBuilder.gif
├── SQLBuilder_view.html
├── SQLExecutor.gif
├── SQLExecutor_view.html
├── SQLMapper.gif
├── SQLMapper_view.html
└── hello_jdbc.gif
├── maven
└── 0.0.1-SNAPSHOT
│ ├── READ ME.txt
│ └── abacus-jdbc-0.0.1-SNAPSHOT.pom
├── pom.xml
├── samples
├── codes
│ └── entity
│ │ ├── Account.java
│ │ ├── User.java
│ │ └── UserQueryAllResult.java
├── com
│ └── landawn
│ │ └── abacus
│ │ └── samples
│ │ ├── CodeGenerationUtilTest.java
│ │ ├── DaoTest.java
│ │ ├── DataSetTest.java
│ │ ├── Hello.java
│ │ ├── JdbcTest.java
│ │ ├── PreparedQueryTest.java
│ │ ├── SQLExecutorTest.java
│ │ ├── UncheckedDaoTest.java
│ │ ├── dao
│ │ ├── AddressDao.java
│ │ ├── DeviceDao.java
│ │ ├── EmployeeDao.java
│ │ ├── EmployeeProjectDao.java
│ │ ├── EmployeeProjectDao2.java
│ │ ├── MyUserDaoA.java
│ │ ├── NoUpdateUserDao.java
│ │ ├── ProjectDao.java
│ │ ├── ReadOnlyUserDao.java
│ │ ├── UncheckedUserDao.java
│ │ ├── UncheckedUserDaoL.java
│ │ ├── UserDao.java
│ │ ├── UserDaoL.java
│ │ └── handler
│ │ │ └── UserDaoHandlerA.java
│ │ └── entity
│ │ ├── Address.java
│ │ ├── Device.java
│ │ ├── Employee.java
│ │ ├── EmployeeProject.java
│ │ ├── ImmutableUser.java
│ │ ├── Project.java
│ │ ├── User.java
│ │ └── s.java
└── userSqlMapper.xml
├── schema
├── DataSource.xsd
└── SQLMapper.xsd
└── src
├── main
└── java
│ └── com
│ └── landawn
│ └── abacus
│ └── jdbc
│ ├── AbstractQuery.java
│ ├── CallableQuery.java
│ ├── DBLock.java
│ ├── DBProductInfo.java
│ ├── DBSequence.java
│ ├── DBVersion.java
│ ├── DaoImpl.java
│ ├── EmptyHandler.java
│ ├── FetchDirection.java
│ ├── IsolationLevel.java
│ ├── Jdbc.java
│ ├── JdbcCodeGenerationUtil.java
│ ├── JdbcSettings.java
│ ├── JdbcUtil.java
│ ├── JdbcUtils.java
│ ├── JoinInfo.java
│ ├── NamedQuery.java
│ ├── OP.java
│ ├── OnDeleteAction.java
│ ├── PreparedQuery.java
│ ├── Propagation.java
│ ├── SQLExecutor.java
│ ├── SQLTransaction.java
│ ├── SpringApplicationContext.java
│ ├── SqlLogConfig.java
│ ├── Transaction.java
│ ├── annotation
│ ├── Bind.java
│ ├── BindList.java
│ ├── Cache.java
│ ├── CacheResult.java
│ ├── Call.java
│ ├── Config.java
│ ├── Define.java
│ ├── DefineList.java
│ ├── Delete.java
│ ├── FetchColumnByEntityClass.java
│ ├── Handler.java
│ ├── HandlerList.java
│ ├── Insert.java
│ ├── MappedByKey.java
│ ├── MergedById.java
│ ├── NonDBOperation.java
│ ├── OnDelete.java
│ ├── OutParameter.java
│ ├── OutParameterList.java
│ ├── PerfLog.java
│ ├── PrefixFieldMapping.java
│ ├── RefreshCache.java
│ ├── Select.java
│ ├── SqlField.java
│ ├── SqlLogEnabled.java
│ ├── SqlMapper.java
│ ├── Sqls.java
│ ├── Transactional.java
│ └── Update.java
│ ├── cs.java
│ └── dao
│ ├── CrudDao.java
│ ├── CrudDaoL.java
│ ├── CrudJoinEntityHelper.java
│ ├── CrudJoinEntityHelperL.java
│ ├── Dao.java
│ ├── DaoUtil.java
│ ├── JoinEntityHelper.java
│ ├── NoUpdateCrudDao.java
│ ├── NoUpdateCrudDaoL.java
│ ├── NoUpdateDao.java
│ ├── ReadOnlyCrudDao.java
│ ├── ReadOnlyCrudDaoL.java
│ ├── ReadOnlyCrudJoinEntityHelper.java
│ ├── ReadOnlyCrudJoinEntityHelperL.java
│ ├── ReadOnlyDao.java
│ ├── ReadOnlyJoinEntityHelper.java
│ ├── UncheckedCrudDao.java
│ ├── UncheckedCrudDaoL.java
│ ├── UncheckedCrudJoinEntityHelper.java
│ ├── UncheckedCrudJoinEntityHelperL.java
│ ├── UncheckedDao.java
│ ├── UncheckedJoinEntityHelper.java
│ ├── UncheckedNoUpdateCrudDao.java
│ ├── UncheckedNoUpdateCrudDaoL.java
│ ├── UncheckedNoUpdateDao.java
│ ├── UncheckedReadOnlyCrudDao.java
│ ├── UncheckedReadOnlyCrudDaoL.java
│ ├── UncheckedReadOnlyCrudJoinEntityHelper.java
│ ├── UncheckedReadOnlyCrudJoinEntityHelperL.java
│ ├── UncheckedReadOnlyDao.java
│ └── UncheckedReadOnlyJoinEntityHelper.java
└── test
└── java
├── com
└── landawn
│ └── abacus
│ ├── CodeHelper.java
│ ├── JavaDocHelper.java
│ └── Maven.java
└── log4j2.xml
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
This is the default setting of a transaction annotation.
23 | */
24 | REQUIRED,
25 |
26 | /**
27 | * Support a current transaction, execute non-transactionally if none exists.
28 | */
29 | SUPPORTS,
30 |
31 | /**
32 | * Create a new transaction, and suspend the current transaction if one exists.
33 | */
34 | REQUIRES_NEW,
35 |
36 | /**
37 | * Execute non-transactionally, suspend the current transaction if one exists.
38 | */
39 | NOT_SUPPORTED
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/SpringApplicationContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.landawn.abacus.jdbc;
18 |
19 | import org.springframework.beans.factory.annotation.Autowired;
20 | import org.springframework.context.ApplicationContext;
21 |
22 | final class SpringApplicationContext {
23 |
24 | @Autowired // NOSONAR
25 | private ApplicationContext appContext;
26 |
27 | SpringApplicationContext() {
28 | }
29 |
30 | /**
31 | *
32 | *
33 | * @param name
34 | * @return
35 | */
36 | public Object getBean(final String name) {
37 | return appContext == null ? null : appContext.getBean(name);
38 | }
39 |
40 | /**
41 | *
42 | *
43 | * @param
27 | *
30 | *
26 | *
28 | *
29 | * @Select("SELECT first_name, last_name FROM {tableName} WHERE id = :id")
30 | *
44 | *
31 | * User selectByUserId(@Define("tableName") String realTableName, @Bind("id") int id) throws SQLException;
32 | *
33 | *
34 | *
35 | *
36 | * OR with customized '{whatever}':
37 | *
38 | *
39 | * @Select("SELECT first_name, last_name FROM {tableName} WHERE id = :id ORDER BY {whatever -> orderBy{{P}}")
40 | *
41 | * User selectByUserId(@Define("tableName") String realTableName, @Bind("id") int id, @Define("{whatever -> orderBy{{P}}") String orderBy) throws SQLException;
42 | *
43 | *
31 | *
32 | * @Select("SELECT id, first_name, last_name FROM user WHERE id in ({ids}")
33 | *
39 | *
34 | * @MappedByKey("id")
35 | *
36 | * Map<Long, User> listUser(@BindList("ids") List
27 | *
28 | * @Select("SELECT id, first_name as \"firstName\", last_name as \"lastName\", devices.id as \"devices.id\", device.model as \"devices.model\" FROM user left join device on user.id = device.user_id WHERE id in ({ids}")
29 | *
35 | *
30 | * @MergedById
31 | *
32 | * List @MergedById("id, date")
.
44 | *
45 | * @return
46 | * @deprecated
47 | */
48 | @Deprecated
49 | String value() default "";
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/NonDBOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | * Annotated methods in {@code Dao} for:
25 | *
26 | *
31 | * By default, {@code targetEntityClass/dataSource/sqlMapper/executor/asyncExecutor/prepareQuery/prepareNamedQuery/prepareCallableQuery} methods in {@code Dao} are annotated with {@code NonDBOperation}.
32 | *
33 | *
34 | *
35 | *
36 | *
37 | */
38 | @Retention(RetentionPolicy.RUNTIME)
39 | @Target(value = { ElementType.METHOD })
40 | public @interface NonDBOperation {
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/OnDelete.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import com.landawn.abacus.jdbc.OnDeleteAction;
24 |
25 | /**
26 | *
27 | * @deprecated won't be implemented. It should be defined and done in DB server side.
28 | */
29 | @Retention(RetentionPolicy.RUNTIME)
30 | @Target(value = { ElementType.METHOD })
31 | @Deprecated
32 | public @interface OnDelete {
33 |
34 | /**
35 | *
36 | *
37 | * @return
38 | */
39 | OnDeleteAction action() default OnDeleteAction.NO_ACTION;
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/OutParameter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Repeatable;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 | import java.sql.CallableStatement;
24 |
25 | @Retention(RetentionPolicy.RUNTIME)
26 | @Target(ElementType.METHOD)
27 | @Repeatable(OutParameterList.class)
28 | public @interface OutParameter {
29 | /**
30 | *
31 | * @return
32 | * @see CallableStatement#registerOutParameter(String, int)
33 | */
34 | String name() default "";
35 |
36 | /**
37 | * Starts from 1.
38 | * @return
39 | * @see CallableStatement#registerOutParameter(int, int)
40 | */
41 | int position() default -1;
42 |
43 | /**
44 | *
45 | * @return
46 | * @see {@code java.sql.Types}
47 | */
48 | int sqlType();
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/OutParameterList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target(ElementType.METHOD)
25 | public @interface OutParameterList {
26 |
27 | /**
28 | *
29 | *
30 | * @return
31 | */
32 | OutParameter[] value();
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/PerfLog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import com.landawn.abacus.jdbc.JdbcUtil;
24 |
25 | @Retention(RetentionPolicy.RUNTIME)
26 | @Target(value = { ElementType.METHOD, ElementType.TYPE })
27 | public @interface PerfLog {
28 | /**
29 | * start to log performance for sql if the execution time >= the specified(or default) execution time in milliseconds.
30 | *
31 | * @return
32 | */
33 | long minExecutionTimeForSql() default JdbcUtil.DEFAULT_MIN_EXECUTION_TIME_FOR_SQL_PERF_LOG; // 1000
34 |
35 | /**
36 | *
37 | *
38 | * @return
39 | */
40 | int maxSqlLogLength() default JdbcUtil.DEFAULT_MAX_SQL_LOG_LENGTH; // 1024
41 |
42 | /**
43 | * start to log performance for Dao operation/method if the execution time >= the specified(or default) execution time in milliseconds.
44 | * @return
45 | */
46 | long minExecutionTimeForOperation() default JdbcUtil.DEFAULT_MIN_EXECUTION_TIME_FOR_DAO_METHOD_PERF_LOG; // 3000
47 |
48 | /**
49 | * Those conditions(by contains ignore case or regular expression match) will be joined by {@code OR}, not {@code AND}.
50 | * It's only applied if target of annotation {@code PerfLog} is {@code Type}, and will be ignored if target is method.
51 | *
52 | * @return
53 | */
54 | String[] filter() default { ".*" };
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/PrefixFieldMapping.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target(value = { ElementType.METHOD })
25 | public @interface PrefixFieldMapping {
26 |
27 | /**
28 | * @PrefixFieldMapping("d=device, c=contact")
.
29 | *
30 | * @return
31 | * @deprecated
32 | */
33 | @Deprecated
34 | String value() default "";
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/RefreshCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import com.landawn.abacus.annotation.Beta;
24 |
25 | @Beta
26 | @Retention(RetentionPolicy.RUNTIME)
27 | @Target(value = { ElementType.METHOD, ElementType.TYPE })
28 | public @interface RefreshCache {
29 |
30 | /**
31 | * Flag to identity if {@code RefreshCache} is disabled.
32 | * @return
33 | */
34 | boolean disabled() default false;
35 |
36 | // /**
37 | // *
38 | // * @return
39 | // */
40 | // boolean forceRefreshStaticData() default false;
41 |
42 | /**
43 | * Those conditions(by contains ignore case or regular expression match) will be joined by {@code OR}, not {@code AND}.
44 | * It's only applied if target of annotation {@code RefreshCache} is {@code Type}, and will be ignored if target is method.
45 | *
46 | * @return
47 | */
48 | String[] filter() default { "update", "delete", "deleteById", "insert", "save", "batchUpdate", "batchDelete", "batchDeleteByIds", "batchInsert",
49 | "batchSave", "batchUpsert", "upsert", "execute" };
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/Select.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import com.landawn.abacus.annotation.Beta;
24 | import com.landawn.abacus.jdbc.OP;
25 |
26 | /**
27 | * The Interface Select.
28 | *
29 | * @see How to turn off the Eclipse code formatter for certain sections of Java code?
30 | */
31 | @Retention(RetentionPolicy.RUNTIME)
32 | @Target(ElementType.METHOD)
33 | public @interface Select {
34 |
35 | /**
36 | * Sql script, or id which is defined in sql mapper or sql table class inside DAO class.
37 | *
38 | * @return
39 | * @deprecated using {@code sql="SELECT ... FROM ..."} or {@code id="selectById"} for explicit call.
40 | */
41 | @Deprecated
42 | String value() default "";
43 |
44 | /**
45 | *
46 | * @return
47 | */
48 | String sql() default "";
49 |
50 | /**
51 | *
52 | * @return
53 | */
54 | String id() default ""; // id defined SqlMapper
55 |
56 | /**
57 | *
58 | * @return
59 | */
60 | int fetchSize() default -1;
61 |
62 | /**
63 | * Unit is seconds.
64 | *
65 | * @return
66 | */
67 | int queryTimeout() default -1;
68 |
69 | /**
70 | * Set it to {@code true} if there is only one input parameter and the type is Collection/Object Array, and the target db column type is Collection/Object Array.
71 | *
72 | * @return
73 | */
74 | boolean isSingleParameter() default false;
75 |
76 | /**
77 | *
78 | * @return
79 | * @see Define
80 | * @see DefineList
81 | */
82 | @Beta
83 | boolean hasDefineWithNamedParameter() default false;
84 |
85 | /**
86 | * Set named parameter {@code :now} to current system time if it's {@code true}.
87 | *
88 | * @return
89 | */
90 | @Beta
91 | boolean timestamped() default false;
92 |
93 | /**
94 | *
95 | *
96 | * @return
97 | */
98 | OP op() default OP.DEFAULT;
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/SqlField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target(ElementType.FIELD)
25 | public @interface SqlField {
26 |
27 | /**
28 | *
29 | * @return
30 | */
31 | String id() default ""; // default will be field name.
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/SqlLogEnabled.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import com.landawn.abacus.jdbc.JdbcUtil;
24 |
25 | /**
26 | *
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(value = { ElementType.METHOD, ElementType.TYPE })
30 | public @interface SqlLogEnabled {
31 |
32 | /**
33 | *
34 | *
35 | * @return
36 | */
37 | boolean value() default true;
38 |
39 | /**
40 | *
41 | *
42 | * @return
43 | */
44 | int maxSqlLogLength() default JdbcUtil.DEFAULT_MAX_SQL_LOG_LENGTH; // 1024
45 |
46 | /**
47 | * Those conditions(by contains ignore case or regular expression match) will be joined by {@code OR}, not {@code AND}.
48 | * It's only applied if target of annotation {@code SqlLogEnabled} is {@code Type}, and will be ignored if target is method.
49 | *
50 | * @return
51 | */
52 | String[] filter() default { ".*" };
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/SqlMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target(value = { ElementType.TYPE })
25 | public @interface SqlMapper {
26 | /**
27 | * Path of the SQL Mapper xml file.
28 | *
29 | * @return
30 | */
31 | String value() default "";
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/Sqls.java:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Copyright (c) 2021, Haiyang Li.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.landawn.abacus.jdbc.annotation;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * It's only for methods with default implementation in {@code Dao} interfaces. Don't use it for the abstract methods.
26 | * And the last parameter of the method should be {@code String[]: (param1, param2, ..., String ... sqls)}
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.METHOD)
30 | public @interface Sqls {
31 |
32 | /**
33 | * Sql script, or id which is defined in sql mapper or sql table class inside DAO class.
34 | *
35 | * @return
36 | */
37 | String[] value() default {};
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/Transactional.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import com.landawn.abacus.jdbc.IsolationLevel;
24 | import com.landawn.abacus.jdbc.Propagation;
25 |
26 | /**
27 | * It's for transaction started in {@code Dao} methods.
28 | * For service classes in Spring, {@code org.springframework.transaction.annotation.Transactional} should be used.
29 | */
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Target(ElementType.METHOD) // Should be used on method only, not for ElementType.TYPE/CLASS
32 | public @interface Transactional {
33 |
34 | /**
35 | *
36 | *
37 | * @return
38 | */
39 | Propagation propagation() default Propagation.REQUIRED;
40 |
41 | /**
42 | *
43 | *
44 | * @return
45 | */
46 | IsolationLevel isolation() default IsolationLevel.DEFAULT;
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/annotation/Update.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.annotation;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import com.landawn.abacus.annotation.Beta;
24 | import com.landawn.abacus.jdbc.JdbcUtil;
25 | import com.landawn.abacus.jdbc.OP;
26 |
27 | /**
28 | * The Interface Update.
29 | *
30 | * @see How to turn off the Eclipse code formatter for certain sections of Java code?
31 | */
32 | @Retention(RetentionPolicy.RUNTIME)
33 | @Target(ElementType.METHOD)
34 | public @interface Update {
35 |
36 | /**
37 | * SQL script, or id which is defined in SQL mapper or SQL table class inside DAO class.
38 | *
39 | * @return
40 | * @deprecated using {@code sql="SELECT ... FROM ..."} or {@code id="selectById"} for explicit call.
41 | */
42 | @Deprecated
43 | String value() default "";
44 |
45 | /**
46 | *
47 | * @return
48 | */
49 | String sql() default "";
50 |
51 | /**
52 | *
53 | * @return
54 | */
55 | String id() default ""; // id defined SqlMapper
56 |
57 | /**
58 | *
59 | * @return
60 | */
61 | boolean isBatch() default false;
62 |
63 | /**
64 | *
65 | * @return
66 | */
67 | int batchSize() default JdbcUtil.DEFAULT_BATCH_SIZE;
68 |
69 | /**
70 | * Unit is seconds.
71 | *
72 | * @return
73 | */
74 | int queryTimeout() default -1;
75 |
76 | /**
77 | * Set it to {@code true} if there is only one input parameter and the type is Collection/Object Array, and the target db column type is Collection/Object Array.
78 | *
79 | * @return
80 | */
81 | boolean isSingleParameter() default false;
82 |
83 | /**
84 | *
85 | * @return
86 | * @see Define
87 | * @see DefineList
88 | */
89 | @Beta
90 | boolean hasDefineWithNamedParameter() default false;
91 |
92 | /**
93 | * Set named parameter {@code :now} to current system time if it's {@code true}.
94 | *
95 | * @return
96 | */
97 | @Beta
98 | boolean timestamped() default false;
99 |
100 | /**
101 | * It should only be set with {@code OP.update} or {@code OP.largeUpdate}
102 | * @return
103 | */
104 | OP op() default OP.update;
105 | }
106 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/cs.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.landawn.abacus.jdbc;
18 |
19 | public final class cs { // NOSONAR
20 | private cs() {
21 | // singleton
22 | }
23 |
24 | public static final String ResultSet = "ResultSet";
25 | public static final String action = "action";
26 | public static final String afterInvokeAction = "afterInvokeAction";
27 | public static final String autoGeneratedKeyExtractor = "autoGeneratedKeyExtractor";
28 | public static final String batchParameters = "batchParameters";
29 | public static final String batchSize = "batchSize";
30 | public static final String beforeInvokeAction = "beforeInvokeAction";
31 | public static final String closeHandler = "closeHandler";
32 | public static final String cmd = "cmd";
33 | public static final String columnGetter = "columnGetter";
34 | public static final String columnIndex = "columnIndex";
35 | public static final String columnName = "columnName";
36 | public static final String cond = "cond";
37 | public static final String conn = "conn";
38 | public static final String consumer = "consumer";
39 | public static final String consumerForAll = "consumerForAll";
40 | public static final String count = "count";
41 | public static final String daoInterface = "daoInterface";
42 | public static final String dataSource = "dataSource";
43 | public static final String defaultColumnGetter = "defaultColumnGetter";
44 | public static final String downstream = "downstream";
45 | public static final String entity = "entity";
46 | public static final String entityClass = "entityClass";
47 | public static final String executor = "executor";
48 | public static final String filter = "filter";
49 | public static final String func = "func";
50 | public static final String getter = "getter";
51 | public static final String handler = "handler";
52 | public static final String handlerClass = "handlerClass";
53 | public static final String idExtractor = "idExtractor";
54 | public static final String isDefaultIdTester = "isDefaultIdTester";
55 | public static final String isolationLevel = "isolationLevel";
56 | public static final String keyExtractor = "keyExtractor";
57 | public static final String mergeFunction = "mergeFunction";
58 | public static final String multimapSupplier = "multimapSupplier";
59 | public static final String n = "n";
60 | public static final String namedSql = "namedSql";
61 | public static final String offset = "offset";
62 | public static final String orElseAction = "orElseAction";
63 | public static final String parameterNames = "parameterNames";
64 | public static final String parameters = "parameters";
65 | public static final String parametersSetter = "parametersSetter";
66 | public static final String paramsSetter = "paramsSetter";
67 | public static final String propNamesToRefresh = "propNamesToRefresh";
68 | public static final String qualifier = "qualifier";
69 | public static final String register = "register";
70 | public static final String resultExtractor = "resultExtractor";
71 | public static final String resultExtractor1 = "resultExtractor1";
72 | public static final String resultExtractor2 = "resultExtractor2";
73 | public static final String resultExtractor3 = "resultExtractor3";
74 | public static final String resultSet = "resultSet"; // NOSONAR
75 | public static final String returnColumnIndexes = "returnColumnIndexes";
76 | public static final String returnColumnNames = "returnColumnNames";
77 | public static final String rowConsumer = "rowConsumer";
78 | public static final String rowExtractor = "rowExtractor";
79 | public static final String rowFilter = "rowFilter";
80 | public static final String rowMapper = "rowMapper";
81 | public static final String rowMapper1 = "rowMapper1";
82 | public static final String rowMapper2 = "rowMapper2";
83 | public static final String rowMapper3 = "rowMapper3";
84 | public static final String sql = "sql";
85 | public static final String sqlAction = "sqlAction";
86 | public static final String sqlAction1 = "sqlAction1";
87 | public static final String sqlAction2 = "sqlAction2";
88 | public static final String sqlAction3 = "sqlAction3";
89 | public static final String stmt = "stmt";
90 | public static final String stmtCreator = "stmtCreator";
91 | public static final String stmtSetter = "stmtSetter";
92 | public static final String supplier = "supplier";
93 | public static final String targetClass = "targetClass";
94 | public static final String targetType = "targetType";
95 | public static final String type = "type";
96 | public static final String uniquePropNamesForQuery = "uniquePropNamesForQuery";
97 | public static final String url = "url";
98 | public static final String valueExtractor = "valueExtractor";
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/com/landawn/abacus/jdbc/dao/NoUpdateCrudDaoL.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, Haiyang Li.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.landawn.abacus.jdbc.dao;
17 |
18 | import java.sql.SQLException;
19 | import java.util.Map;
20 |
21 | import com.landawn.abacus.annotation.Beta;
22 | import com.landawn.abacus.util.SQLBuilder;
23 |
24 | @SuppressWarnings("RedundantThrows")
25 | @Beta
26 | public interface NoUpdateCrudDaoL
32 | * @see com.landawn.abacus.condition.ConditionFactory
33 | * @see com.landawn.abacus.condition.ConditionFactory.CF
34 | */
35 | @SuppressWarnings("RedundantThrows")
36 | @Beta
37 | public interface ReadOnlyCrudDao the type of the CRUD DAO
26 | */
27 | public interface ReadOnlyCrudJoinEntityHelperL
34 | * @see com.landawn.abacus.condition.ConditionFactory
35 | * @see com.landawn.abacus.condition.ConditionFactory.CF
36 | */
37 | @Beta
38 | public interface UncheckedNoUpdateDao
32 | */
33 | @Beta
34 | public interface UncheckedReadOnlyCrudDao
30 | */
31 | @Beta
32 | public interface UncheckedReadOnlyDao