├── .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 | 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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.factorypath 3 | /.idea/ 4 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | abacus-jdbc 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.jdt.core.javanature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.core.resources.prefs 2 | /org.eclipse.jdt.apt.core.prefs 3 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /docs/CSVUtil.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/CSVUtil.gif -------------------------------------------------------------------------------- /docs/CSVUtil_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of CSVUtil 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/CallableQuery.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/CallableQuery.gif -------------------------------------------------------------------------------- /docs/CallableQuery_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of CallableQuery 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/Columns.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/Columns.gif -------------------------------------------------------------------------------- /docs/Columns_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of Columns 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/ConditionFactory.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/ConditionFactory.gif -------------------------------------------------------------------------------- /docs/ConditionFactory_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of ConditionFactory 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/CrudDao.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/CrudDao.gif -------------------------------------------------------------------------------- /docs/CrudDao_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of CrudDao 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/Dao.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/Dao.gif -------------------------------------------------------------------------------- /docs/Dao_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of Dao 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/DataSet.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/DataSet.gif -------------------------------------------------------------------------------- /docs/DataSet_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of DataSet 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/DynamicSQLBuilder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/DynamicSQLBuilder.gif -------------------------------------------------------------------------------- /docs/DynamicSQLBuilder_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of DynamicSQLBuilder 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/Jdbc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/Jdbc.gif -------------------------------------------------------------------------------- /docs/JdbcContext.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/JdbcContext.gif -------------------------------------------------------------------------------- /docs/JdbcContext_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of JdbcContext 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/JdbcUtil.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/JdbcUtil.gif -------------------------------------------------------------------------------- /docs/JdbcUtil_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of JdbcUtil 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/JdbcUtils.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/JdbcUtils.gif -------------------------------------------------------------------------------- /docs/JdbcUtils_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of JdbcUtils 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/Jdbc_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of Jdbc 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/JoinEntityHelper.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/JoinEntityHelper.gif -------------------------------------------------------------------------------- /docs/JoinEntityHelper_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of JoinEntityHelper 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/Mapper.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/Mapper.gif -------------------------------------------------------------------------------- /docs/Mapper_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of Mapper 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/NamedQuery.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/NamedQuery.gif -------------------------------------------------------------------------------- /docs/NamedQuery_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of NamedQuery 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/PreparedQuery.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/PreparedQuery.gif -------------------------------------------------------------------------------- /docs/PreparedQuery_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of PreparedQuery 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/SQLBuilder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/SQLBuilder.gif -------------------------------------------------------------------------------- /docs/SQLBuilder_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of SQLBuilder 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/SQLExecutor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/SQLExecutor.gif -------------------------------------------------------------------------------- /docs/SQLExecutor_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of SQLExecutor 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/SQLMapper.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/SQLMapper.gif -------------------------------------------------------------------------------- /docs/SQLMapper_view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Panoramic View of Mapper 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/hello_jdbc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landawn/abacus-jdbc/68e1e1f5e0b9fa5b6c4adfbda0476bcef8827337/docs/hello_jdbc.gif -------------------------------------------------------------------------------- /maven/0.0.1-SNAPSHOT/READ ME.txt: -------------------------------------------------------------------------------- 1 | ######## Method 1 ############################################ 2 | 3 | 1, Read http://central.sonatype.org/pages/apache-maven.html and generate key by instructions: http://central.sonatype.org/pages/working-with-pgp-signatures.html 4 | 5 | 2, copy settings-security.xml and settings.xml to folder: C:\Users\haiyangl\.m2\ 6 | 7 | 3, Deploy and Release: 8 | mvn clean deploy -f abacus-jdbc-0.0.1-SNAPSHOT.pom 9 | 10 | 11 | ######## Method 2 ############################################ 12 | 13 | 1, download Gpg4win at: https://www.gpg4win.org/download.html 14 | 15 | 2, create key pair by kleopatra UI tools: File -> New Certificate... -> Create a personal OpenPGP key pair. 16 | 17 | 3, add public key server by: menu/command: Settings -> Configure Kleopatra -> input 'keyserver.ubuntu.com' in 'Server Name' column. 18 | 19 | 4, exports public key to server by: Select the create key and click right mouse button to pop up menu -> exports certificates to server ... 20 | 21 | 5, public repository: https://oss.sonatype.org/content/groups/public/com/landawn 22 | 23 | ======================abacus-jdbc======================================= 24 | mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=abacus-jdbc-0.0.1-SNAPSHOT.pom -Dfile=abacus-jdbc-0.0.1-SNAPSHOT.jar 25 | mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=abacus-jdbc-0.0.1-SNAPSHOT.pom -Dfile=abacus-jdbc-0.0.1-SNAPSHOT-javadoc.jar 26 | mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=abacus-jdbc-0.0.1-SNAPSHOT.pom -Dfile=abacus-jdbc-0.0.1-SNAPSHOT-sources.jar 27 | 28 | jar -cvf abacus-jdbc-0.0.1-SNAPSHOT-bundle.jar abacus-jdbc-0.0.1-SNAPSHOT.pom abacus-jdbc-0.0.1-SNAPSHOT.pom.asc abacus-jdbc-0.0.1-SNAPSHOT.jar abacus-jdbc-0.0.1-SNAPSHOT.jar.asc abacus-jdbc-0.0.1-SNAPSHOT-javadoc.jar abacus-jdbc-0.0.1-SNAPSHOT-javadoc.jar.asc abacus-jdbc-0.0.1-SNAPSHOT-sources.jar abacus-jdbc-0.0.1-SNAPSHOT-sources.jar.asc 29 | 30 | -------------------------------------------------------------------------------- /maven/0.0.1-SNAPSHOT/abacus-jdbc-0.0.1-SNAPSHOT.pom: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.landawn 6 | abacus-jdbc 7 | 0.0.1-SNAPSHOT 8 | jar 9 | abacus-jdbc 10 | abacus jdbc 11 | https://github.com/landawn/abacus-jdbc 12 | 13 | 14 | 15 | The Apache License, Version 2.0 16 | https://github.com/landawn/abacus-jdbc/blob/master/LICENSE.txt 17 | 18 | 19 | 20 | 21 | 22 | Haiyang Li 23 | 70lihy@gmail.com 24 | 25 | 26 | 27 | 28 | scm:git:https://github.com/landawn/abacus-jdbc.git 29 | scm:git:https://github.com/landawn/abacus-jdbc.git 30 | https://github.com/landawn/abacus-jdbc 31 | 32 | 33 | 34 | 35 | ossrh 36 | https://oss.sonatype.org/content/repositories/snapshots 37 | 38 | 39 | ossrh 40 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-gpg-plugin 50 | 1.5 51 | 52 | 53 | sign-artifacts 54 | verify 55 | 56 | sign 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.sonatype.plugins 64 | nexus-staging-maven-plugin 65 | 1.6.6 66 | true 67 | 68 | ossrh 69 | https://oss.sonatype.org/ 70 | true 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | com.landawn 79 | abacus-common 80 | 5.8.8 81 | 82 | 83 | 84 | com.landawn 85 | abacus-query 86 | 2.2.1 87 | 88 | 89 | 90 | com.landawn 91 | abacus-cache 92 | 1.3.5 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /samples/codes/entity/Account.java: -------------------------------------------------------------------------------- 1 | package codes.entity; 2 | 3 | import com.landawn.abacus.annotation.Column; 4 | import com.landawn.abacus.annotation.Id; 5 | import com.landawn.abacus.annotation.NonUpdatable; 6 | import com.landawn.abacus.annotation.ReadOnly; 7 | import com.landawn.abacus.annotation.Table; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Builder; 11 | import lombok.Data; 12 | import lombok.NoArgsConstructor; 13 | 14 | @Builder 15 | @Data 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | @Table("account") 19 | public class Account { 20 | 21 | @Id 22 | @NonUpdatable 23 | @Column("ID") 24 | private long id; 25 | 26 | @Column("FIRST_NAME") 27 | private String firstName; 28 | 29 | @Column("LAST_NAME") 30 | private String lastName; 31 | 32 | @Column("EMAIL_ADDRESS") 33 | private String emailAddress; 34 | 35 | @ReadOnly 36 | @Column("CREATE_TIME") 37 | private java.sql.Timestamp createTime; 38 | 39 | /** 40 | * Auto-generated class for property(field) name table. 41 | */ 42 | public interface x { // NOSONAR 43 | 44 | /** Property(field) name {@code "id"} */ 45 | String id = "id"; 46 | 47 | /** Property(field) name {@code "firstName"} */ 48 | String firstName = "firstName"; 49 | 50 | /** Property(field) name {@code "lastName"} */ 51 | String lastName = "lastName"; 52 | 53 | /** Property(field) name {@code "emailAddress"} */ 54 | String emailAddress = "emailAddress"; 55 | 56 | /** Property(field) name {@code "createTime"} */ 57 | String createTime = "createTime"; 58 | 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /samples/codes/entity/User.java: -------------------------------------------------------------------------------- 1 | package codes.entity; 2 | 3 | import jakarta.persistence.Column; 4 | import javax.persistence.Id; 5 | 6 | import com.landawn.abacus.annotation.JsonXmlConfig; 7 | import com.landawn.abacus.annotation.NonUpdatable; 8 | import com.landawn.abacus.annotation.ReadOnly; 9 | import com.landawn.abacus.annotation.Table; 10 | import com.landawn.abacus.annotation.Type; 11 | import com.landawn.abacus.annotation.Type.EnumBy; 12 | import com.landawn.abacus.util.NamingPolicy; 13 | 14 | import lombok.AllArgsConstructor; 15 | import lombok.Builder; 16 | import lombok.Data; 17 | import lombok.NoArgsConstructor; 18 | import lombok.experimental.Accessors; 19 | 20 | @Builder 21 | @Data 22 | @NoArgsConstructor 23 | @AllArgsConstructor 24 | @Accessors(chain = true) 25 | @JsonXmlConfig(namingPolicy = NamingPolicy.UPPER_CASE_WITH_UNDERSCORE, ignoredFields = { "id", "create_time" }, dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'", timeZone = "PDT", numberFormat = "#.###", enumerated = EnumBy.ORDINAL) 26 | @Table("user1") 27 | public class User { 28 | 29 | @Id 30 | @ReadOnly 31 | @Column(name = "ID") 32 | private Long id; 33 | 34 | @Column(name = "FIRST_NAME") 35 | private String firstName; 36 | 37 | @Column(name = "LAST_NAME") 38 | private String lastName; 39 | 40 | @Column(name = "PROP1") 41 | private String prop1; 42 | 43 | @Column(name = "EMAIL") 44 | private String email; 45 | 46 | @NonUpdatable 47 | @Column(name = "CREATE_TIME") 48 | @Type(name = "List") 49 | private java.util.Date create_time; 50 | 51 | public User copy() { 52 | final User copy = new User(); 53 | copy.id = this.id; 54 | copy.firstName = this.firstName; 55 | copy.lastName = this.lastName; 56 | copy.prop1 = this.prop1; 57 | copy.email = this.email; 58 | copy.create_time = this.create_time; 59 | return copy; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /samples/codes/entity/UserQueryAllResult.java: -------------------------------------------------------------------------------- 1 | package codes.entity; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | import jakarta.persistence.Column; 7 | import javax.persistence.Id; 8 | 9 | import com.landawn.abacus.annotation.JsonXmlConfig; 10 | import com.landawn.abacus.annotation.NonUpdatable; 11 | import com.landawn.abacus.annotation.ReadOnly; 12 | import com.landawn.abacus.annotation.Table; 13 | import com.landawn.abacus.annotation.Type; 14 | import com.landawn.abacus.annotation.Type.EnumBy; 15 | import com.landawn.abacus.util.NamingPolicy; 16 | 17 | import lombok.AllArgsConstructor; 18 | import lombok.Builder; 19 | import lombok.Data; 20 | import lombok.NoArgsConstructor; 21 | import lombok.experimental.Accessors; 22 | 23 | @Builder 24 | @Data 25 | @NoArgsConstructor 26 | @AllArgsConstructor 27 | @Accessors(chain = true) 28 | @JsonXmlConfig(namingPolicy = NamingPolicy.UPPER_CASE_WITH_UNDERSCORE, ignoredFields = { "id", "create_time" }, dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'", timeZone = "PDT", numberFormat = "#.###", enumerated = EnumBy.ORDINAL) 29 | @Table("UserQueryAllResult") 30 | public class UserQueryAllResult { 31 | 32 | @Id 33 | @ReadOnly 34 | @Column(name = "ID") 35 | private Long id; 36 | 37 | @Column(name = "FIRST_NAME") 38 | private String firstName; 39 | 40 | @Column(name = "LAST_NAME") 41 | private String lastName; 42 | 43 | @Column(name = "PROP1") 44 | private String prop1; 45 | 46 | @Column(name = "EMAIL") 47 | private String email; 48 | 49 | @NonUpdatable 50 | @Column(name = "CREATE_TIME") 51 | @Type(name = "List") 52 | private java.util.Date create_time; 53 | 54 | // test 55 | private List users; 56 | 57 | private Set userSet; // test 58 | 59 | public UserQueryAllResult copy() { 60 | final UserQueryAllResult copy = new UserQueryAllResult(); 61 | copy.id = this.id; 62 | copy.firstName = this.firstName; 63 | copy.lastName = this.lastName; 64 | copy.prop1 = this.prop1; 65 | copy.email = this.email; 66 | copy.create_time = this.create_time; 67 | copy.users = this.users; 68 | copy.userSet = this.userSet; 69 | return copy; 70 | } 71 | 72 | /* 73 | * Auto-generated class for property(field) name table by abacus-jdbc. 74 | */ 75 | public interface x { // NOSONAR 76 | 77 | /** Property(field) name {@code "id"} */ 78 | String id = "id"; 79 | 80 | /** Property(field) name {@code "firstName"} */ 81 | String firstName = "firstName"; 82 | 83 | /** Property(field) name {@code "lastName"} */ 84 | String lastName = "lastName"; 85 | 86 | /** Property(field) name {@code "prop1"} */ 87 | String prop1 = "prop1"; 88 | 89 | /** Property(field) name {@code "email"} */ 90 | String email = "email"; 91 | 92 | /** Property(field) name {@code "create_time"} */ 93 | String create_time = "create_time"; 94 | 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/CodeGenerationUtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples; 15 | 16 | import static com.landawn.abacus.samples.JdbcTest.dataSource; 17 | 18 | import java.io.File; 19 | import java.util.Collection; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | import com.landawn.abacus.annotation.Type.EnumBy; 24 | import com.landawn.abacus.jdbc.JdbcCodeGenerationUtil; 25 | import com.landawn.abacus.jdbc.JdbcCodeGenerationUtil.EntityCodeConfig; 26 | import com.landawn.abacus.samples.entity.User; 27 | import com.landawn.abacus.util.ClassUtil; 28 | import com.landawn.abacus.util.CodeGenerationUtil; 29 | import com.landawn.abacus.util.CodeGenerationUtil.PropNameTableCodeConfig; 30 | import com.landawn.abacus.util.IOUtil; 31 | import com.landawn.abacus.util.N; 32 | import com.landawn.abacus.util.NamingPolicy; 33 | import com.landawn.abacus.util.SQLBuilder.SCSB; 34 | import com.landawn.abacus.util.Tuple; 35 | 36 | import codes.entity.Account; 37 | 38 | class CodeGenerationUtilTest { 39 | 40 | @Test 41 | public void test_generatePropNameTableClasses() { 42 | N.println(CodeGenerationUtil.generatePropNameTableClass(Account.class, CodeGenerationUtil.X, "./samples")); 43 | 44 | final Collection> classes = N.concat(ClassUtil.getClassesByPackage(User.class.getPackageName(), false, false)); 45 | 46 | final PropNameTableCodeConfig codeConfig = PropNameTableCodeConfig.builder() 47 | .entityClasses(classes) 48 | .className(CodeGenerationUtil.S) 49 | .packageName("com.landawn.abacus.samples.entity") 50 | .srcDir("./samples") 51 | .propNameConverter((cls, propName) -> propName.equals("create_time") ? "createTime" : propName) 52 | .generateClassPropNameList(true) 53 | .generateLowerCaseWithUnderscore(true) 54 | .generateUpperCaseWithUnderscore(true) 55 | .generateFunctionPropName(true) 56 | .functionClassName("f") 57 | .propFunctions(N.asLinkedHashMap("min", CodeGenerationUtil.MIN_FUNC, "max", CodeGenerationUtil.MAX_FUNC)) 58 | .build(); 59 | 60 | N.println(CodeGenerationUtil.generatePropNameTableClasses(codeConfig)); 61 | } 62 | 63 | @Test 64 | public void test_generateEntityClass() { 65 | 66 | EntityCodeConfig ecc = EntityCodeConfig.builder() 67 | .packageName("codes.entity") 68 | .srcDir("./samples") 69 | .idField("id") 70 | .readOnlyFields(N.asSet("createTime")) 71 | .nonUpdatableFields(N.asSet("id")) 72 | .generateBuilder(true) 73 | .build(); 74 | 75 | String str = JdbcCodeGenerationUtil.generateEntityClass(dataSource, "user1", ecc); 76 | System.out.println(str); 77 | 78 | ecc = EntityCodeConfig.builder() 79 | .className("User") 80 | .packageName("codes.entity") 81 | .srcDir("./samples") 82 | .useBoxedType(true) 83 | .readOnlyFields(N.asSet("id")) 84 | .idField("id") 85 | .nonUpdatableFields(N.asSet("create_time")) 86 | .idAnnotationClass(javax.persistence.Id.class) 87 | .columnAnnotationClass(jakarta.persistence.Column.class) 88 | .tableAnnotationClass(com.landawn.abacus.annotation.Table.class) 89 | .customizedFields(N.asList(Tuple.of("create_time", "create_time", java.util.Date.class))) 90 | .customizedFieldDbTypes(N.asList(Tuple.of("create_time", "List"))) 91 | .chainAccessor(true) 92 | .generateBuilder(true) 93 | .generateCopyMethod(true) 94 | .jsonXmlConfig(EntityCodeConfig.JsonXmlConfig.builder() 95 | .namingPolicy(NamingPolicy.UPPER_CASE_WITH_UNDERSCORE) 96 | .ignoredFields("id, create_time") 97 | .dateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") 98 | .numberFormat("#.###") 99 | .timeZone("PDT") 100 | .enumerated(EnumBy.ORDINAL) 101 | .build()) 102 | .build(); 103 | 104 | str = JdbcCodeGenerationUtil.generateEntityClass(dataSource, "user1", ecc); 105 | System.out.println(str); 106 | 107 | final String additionalLines = """ 108 | // test 109 | private List users; 110 | 111 | private Set userSet; // test 112 | """; 113 | 114 | ecc.setClassName("UserQueryAllResult"); 115 | ecc.setAdditionalFieldsOrLines(additionalLines); 116 | ecc.setGenerateFieldNameTable(true); 117 | str = JdbcCodeGenerationUtil.generateEntityClass(dataSource, "UserQueryAllResult", "select * from user1", ecc); 118 | System.out.println(str); 119 | 120 | IOUtil.deleteIfExists(new File("./samples/codes/entity/User1.java")); 121 | } 122 | 123 | @Test 124 | public void test_generateSql() { 125 | String sql = JdbcCodeGenerationUtil.generateSelectSql(dataSource, "user1"); 126 | N.println(sql); 127 | 128 | sql = JdbcCodeGenerationUtil.generateInsertSql(dataSource, "user1"); 129 | N.println(sql); 130 | 131 | sql = JdbcCodeGenerationUtil.generateNamedInsertSql(dataSource, "user1"); 132 | N.println(sql); 133 | 134 | sql = JdbcCodeGenerationUtil.generateUpdateSql(dataSource, "user1"); 135 | N.println(sql); 136 | 137 | sql = JdbcCodeGenerationUtil.generateNamedUpdateSql(dataSource, "user1"); 138 | N.println(sql); 139 | } 140 | 141 | @Test 142 | public void test_convertInsertSqlToUpdateSql() { 143 | User user = N.fill(User.class); 144 | user.setEmail(null); 145 | 146 | String sql = SCSB.insert(user).into(User.class).sql(); 147 | N.println(sql); 148 | 149 | String updateSql = JdbcCodeGenerationUtil.convertInsertSqlToUpdateSql(sql); 150 | N.println(updateSql); 151 | 152 | N.println("=================================="); 153 | 154 | sql = SCSB.insert(user).into(User.class).sql(); 155 | N.println(sql); 156 | 157 | updateSql = JdbcCodeGenerationUtil.convertInsertSqlToUpdateSql(sql, "id > 2"); 158 | N.println(updateSql); 159 | 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/DataSetTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples; 15 | 16 | import java.util.Random; 17 | 18 | import org.junit.jupiter.api.Test; 19 | 20 | import com.landawn.abacus.samples.entity.Address; 21 | import com.landawn.abacus.samples.entity.User; 22 | import com.landawn.abacus.util.DataSet; 23 | import com.landawn.abacus.util.N; 24 | 25 | public class DataSetTest { 26 | static final Random RAND = new Random(); 27 | 28 | @Test 29 | public void test_join() { 30 | final User user = User.builder().id(1001).firstName("Tom").build(); 31 | final Address address = Address.builder().id(2001).userId(1001).street("1 Rd").build(); 32 | 33 | final DataSet ds1 = N.newDataSet(N.asList("id", "firstName"), N.asList(user)); 34 | ds1.println(); 35 | 36 | final DataSet ds2 = N.newDataSet(N.asList("id", "userId", "street"), N.asList(address)); 37 | ds2.renameColumn("id", "addressId"); 38 | ds2.println(); 39 | 40 | final DataSet ds3 = ds1.innerJoin(ds2, N.asMap("id", "userId")); 41 | ds3.println(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/Hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples; 15 | 16 | public class Hello { 17 | } 18 | -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/SQLExecutorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples; 15 | 16 | /** 17 | * All I want to do is: insert -> read -> update -> delete a record in DB table. 18 | */ 19 | public class SQLExecutorTest { 20 | 21 | // @Test 22 | // public void batch_stream() throws SQLException { 23 | // List users = N.fill(User.class, 99); 24 | // String sql_insert = NSC.insertInto(User.class, N.asSet("id")).sql(); 25 | // List ids = sqlExecutor.batchInsert(sql_insert, users); 26 | // String sql = NSC.selectFrom(User.class).where(CF.in("id", ids)).sql(); 27 | // 28 | // for (int i = 0; i < 1000; i++) { 29 | // assertEquals(99, sqlExecutor.stream(User.class, sql, ids).count()); 30 | // } 31 | // 32 | // for (int i = 0; i < 1000; i++) { 33 | // try { 34 | // sqlExecutor.stream(User.class, "select * from user where idd > 1").count(); 35 | // fail("Should throw UncheckedSQLException"); 36 | // } catch (UncheckedSQLException e) { 37 | // 38 | // } 39 | // } 40 | // 41 | // userDao.delete(CF.alwaysTrue()); 42 | // } 43 | // 44 | // @Test 45 | // public void batch_01() throws SQLException { 46 | // 47 | // List users = N.fill(User.class, 99); 48 | // String sql_insert = NSC.insertInto(User.class, N.asSet("id")).sql(); 49 | // JdbcSettings jdbcSettings = JdbcSettings.create().setBatchSize(1000); 50 | // // insert 99 users, less the specified batch size. 51 | // List ids = sqlExecutor.batchInsert(sql_insert, jdbcSettings, users); 52 | // N.println(ids); 53 | // 54 | // assertEquals(users.size(), ids.size()); 55 | // 56 | // SP sp = NSC.selectFrom(User.class).where(CF.in("id", ids)).pair(); 57 | // sqlExecutor.query(sp.sql, sp.parameters).println(); 58 | // 59 | // // insert 3001 users, bigger the specified batch size. 60 | // users = N.fill(User.class, 3001); 61 | // ids = sqlExecutor.batchInsert(sql_insert, jdbcSettings, users); 62 | // N.println(ids); 63 | // 64 | // assertEquals(users.size(), ids.size()); 65 | // 66 | // sp = NSC.selectFrom(User.class).where(CF.in("id", ids)).pair(); 67 | // sqlExecutor.query(sp.sql, sp.parameters).println(); 68 | // 69 | // userDao.delete(CF.alwaysTrue()); 70 | // } 71 | // 72 | // @Test 73 | // public void batch_25() throws SQLException { 74 | // List users = N.fill(User.class, 19764); 75 | // String sql_insert = NSC.insertInto(User.class, N.asSet("id")).sql(); 76 | // JdbcSettings jdbcSettings = JdbcSettings.create().setBatchSize(5000); 77 | // // insert 99 users, less the specified batch size. 78 | // List ids = sqlExecutor.batchInsert(sql_insert, jdbcSettings, users); 79 | // 80 | // assertEquals(users.size(), ids.size()); 81 | // 82 | // SP sp = NSC.selectFrom(User.class).where(CF.in("id", ids)).pair(); 83 | // assertEquals(users.size(), sqlExecutor.query(sp.sql, sp.parameters).size()); 84 | // 85 | // userDao.delete(CF.alwaysTrue()); 86 | // } 87 | } 88 | -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/AddressDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.dao.CrudDaoL; 17 | import com.landawn.abacus.samples.entity.Address; 18 | import com.landawn.abacus.util.SQLBuilder; 19 | 20 | public interface AddressDao extends CrudDaoL { 21 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/DeviceDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.dao.CrudDao; 17 | import com.landawn.abacus.samples.entity.Device; 18 | import com.landawn.abacus.util.SQLBuilder; 19 | 20 | public interface DeviceDao extends CrudDao { 21 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/EmployeeDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.annotation.SqlLogEnabled; 17 | import com.landawn.abacus.jdbc.dao.CrudDao; 18 | import com.landawn.abacus.jdbc.dao.JoinEntityHelper; 19 | import com.landawn.abacus.samples.entity.Employee; 20 | import com.landawn.abacus.util.SQLBuilder; 21 | 22 | @SqlLogEnabled 23 | public interface EmployeeDao extends CrudDao, JoinEntityHelper { 24 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/EmployeeProjectDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.dao.CrudDao; 17 | import com.landawn.abacus.samples.entity.EmployeeProject; 18 | import com.landawn.abacus.util.EntityId; 19 | import com.landawn.abacus.util.SQLBuilder; 20 | 21 | public interface EmployeeProjectDao extends CrudDao { 22 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/EmployeeProjectDao2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.dao.CrudDao; 17 | import com.landawn.abacus.samples.entity.EmployeeProject; 18 | import com.landawn.abacus.util.SQLBuilder; 19 | 20 | public interface EmployeeProjectDao2 extends CrudDao { 21 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/MyUserDaoA.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.annotation.Config; 17 | import com.landawn.abacus.jdbc.annotation.Handler; 18 | import com.landawn.abacus.jdbc.annotation.PerfLog; 19 | import com.landawn.abacus.samples.dao.handler.UserDaoHandlerA; 20 | 21 | @PerfLog(minExecutionTimeForSql = 101, minExecutionTimeForOperation = 100) 22 | @Handler(type = UserDaoHandlerA.class) 23 | @Handler(qualifier = "handler1", filter = ".*") 24 | @Handler(qualifier = "handler2", filter = ".*", isForInvokeFromOutsideOfDaoOnly = true) 25 | @Config(addLimitForSingleQuery = true, callGenerateIdForInsertIfIdNotSet = false) 26 | public interface MyUserDaoA extends UserDao { 27 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/NoUpdateUserDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.annotation.Cache; 17 | import com.landawn.abacus.jdbc.annotation.CacheResult; 18 | import com.landawn.abacus.jdbc.annotation.RefreshCache; 19 | import com.landawn.abacus.jdbc.dao.NoUpdateCrudDao; 20 | import com.landawn.abacus.samples.entity.User; 21 | import com.landawn.abacus.util.SQLBuilder; 22 | 23 | @CacheResult(transfer = "none") 24 | @Cache(capacity = 1000, evictDelay = 6000) 25 | @RefreshCache 26 | public interface NoUpdateUserDao extends NoUpdateCrudDao { 27 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/ProjectDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.annotation.SqlLogEnabled; 17 | import com.landawn.abacus.jdbc.dao.CrudDao; 18 | import com.landawn.abacus.jdbc.dao.JoinEntityHelper; 19 | import com.landawn.abacus.samples.entity.Project; 20 | import com.landawn.abacus.util.SQLBuilder; 21 | 22 | @SqlLogEnabled(true) 23 | public interface ProjectDao extends CrudDao, JoinEntityHelper { 24 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/ReadOnlyUserDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.annotation.Cache; 17 | import com.landawn.abacus.jdbc.annotation.CacheResult; 18 | import com.landawn.abacus.jdbc.annotation.RefreshCache; 19 | import com.landawn.abacus.jdbc.dao.ReadOnlyCrudDao; 20 | import com.landawn.abacus.samples.entity.User; 21 | import com.landawn.abacus.util.SQLBuilder; 22 | 23 | @CacheResult(transfer = "none") 24 | @Cache(capacity = 1000, evictDelay = 6000) 25 | @RefreshCache 26 | public interface ReadOnlyUserDao extends ReadOnlyCrudDao { 27 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/UncheckedUserDaoL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.annotation.PerfLog; 17 | import com.landawn.abacus.jdbc.dao.UncheckedCrudDaoL; 18 | import com.landawn.abacus.jdbc.dao.UncheckedReadOnlyCrudJoinEntityHelper; 19 | import com.landawn.abacus.samples.entity.User; 20 | import com.landawn.abacus.util.SQLBuilder; 21 | 22 | @PerfLog(minExecutionTimeForSql = 101, minExecutionTimeForOperation = 100) 23 | public interface UncheckedUserDaoL extends UncheckedCrudDaoL, 24 | UncheckedReadOnlyCrudJoinEntityHelper { 25 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/UserDaoL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao; 15 | 16 | import com.landawn.abacus.jdbc.annotation.PerfLog; 17 | import com.landawn.abacus.jdbc.dao.CrudDaoL; 18 | import com.landawn.abacus.jdbc.dao.JoinEntityHelper; 19 | import com.landawn.abacus.samples.entity.User; 20 | import com.landawn.abacus.util.SQLBuilder; 21 | 22 | @PerfLog(minExecutionTimeForSql = 101, minExecutionTimeForOperation = 100) 23 | public interface UserDaoL extends CrudDaoL, JoinEntityHelper { 24 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/dao/handler/UserDaoHandlerA.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus.samples.dao.handler; 15 | 16 | import java.lang.reflect.Method; 17 | 18 | import com.landawn.abacus.jdbc.Jdbc; 19 | import com.landawn.abacus.samples.dao.UserDao; 20 | import com.landawn.abacus.util.ImmutableList; 21 | import com.landawn.abacus.util.N; 22 | import com.landawn.abacus.util.Tuple.Tuple3; 23 | 24 | public class UserDaoHandlerA implements Jdbc.Handler { 25 | 26 | /** 27 | * 28 | * 29 | * @param userDao 30 | * @param args 31 | * @param methodSignature 32 | */ 33 | @Override 34 | public void beforeInvoke(final UserDao userDao, final Object[] args, final Tuple3>, Class> methodSignature) { 35 | N.println(">>>UserDaoHandlerA.beforeInvoke: method: " + methodSignature._1.getName()); 36 | } 37 | 38 | /** 39 | * 40 | * 41 | * @param result 42 | * @param userDao 43 | * @param args 44 | * @param methodSignature 45 | */ 46 | @Override 47 | public void afterInvoke(final Object result, final UserDao userDao, final Object[] args, 48 | final Tuple3>, Class> methodSignature) { 49 | N.println("<< projects; 25 | } 26 | -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/entity/EmployeeProject.java: -------------------------------------------------------------------------------- 1 | package com.landawn.abacus.samples.entity; 2 | 3 | import com.landawn.abacus.annotation.Id; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Builder 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Id({ "employeeId", "projectId" }) 15 | public class EmployeeProject { 16 | private int employeeId; 17 | private int projectId; 18 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/entity/ImmutableUser.java: -------------------------------------------------------------------------------- 1 | package com.landawn.abacus.samples.entity; 2 | 3 | import java.sql.Timestamp; 4 | import java.util.List; 5 | 6 | import com.landawn.abacus.annotation.Column; 7 | import com.landawn.abacus.annotation.Id; 8 | import com.landawn.abacus.annotation.JoinedBy; 9 | import com.landawn.abacus.annotation.ReadOnly; 10 | 11 | import lombok.Builder; 12 | import lombok.Value; 13 | 14 | // Entity Object mapped to record in DB table. 15 | @Builder 16 | @Value 17 | public class ImmutableUser { 18 | @Id 19 | private long id; 20 | 21 | @Column("FIRST_NAME") 22 | private String firstName; 23 | private String lastName; 24 | 25 | @Column("prop1") 26 | private String nickName; 27 | private String email; 28 | @ReadOnly 29 | private Timestamp createTime; 30 | 31 | @JoinedBy("id=userId") 32 | private List devices; 33 | 34 | // Supposed to be empty. 35 | @JoinedBy("id=userId, firstName=model") 36 | private Device devices2; 37 | 38 | @JoinedBy("id=userId") 39 | private Address address; 40 | 41 | @JoinedBy({ "id=userId", "lastName=street" }) 42 | private List
address2; 43 | } -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/entity/Project.java: -------------------------------------------------------------------------------- 1 | package com.landawn.abacus.samples.entity; 2 | 3 | import java.util.Date; 4 | import java.util.Set; 5 | 6 | import com.landawn.abacus.annotation.Id; 7 | import com.landawn.abacus.annotation.JoinedBy; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Builder; 11 | import lombok.Data; 12 | import lombok.NoArgsConstructor; 13 | 14 | @Builder 15 | @Data 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | public class Project { 19 | @Id 20 | private int projectId; 21 | private String title; 22 | private Date startDate; 23 | 24 | @JoinedBy({ "projectId=EmployeeProject.projectId", "EmployeeProject.employeeId = employeeId" }) 25 | private Set employees; 26 | } 27 | -------------------------------------------------------------------------------- /samples/com/landawn/abacus/samples/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.landawn.abacus.samples.entity; 2 | 3 | import java.sql.Timestamp; 4 | import java.util.List; 5 | 6 | import com.landawn.abacus.annotation.Column; 7 | import com.landawn.abacus.annotation.Id; 8 | import com.landawn.abacus.annotation.JoinedBy; 9 | import com.landawn.abacus.annotation.ReadOnly; 10 | import com.landawn.abacus.annotation.Table; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Builder; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | 17 | // Entity Object mapped to record in DB table. 18 | @Builder 19 | @Data 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | @Table("user1") 23 | public class User { 24 | @Id 25 | private long id; 26 | 27 | @Column("FIRST_NAME") 28 | private String firstName; 29 | private String lastName; 30 | 31 | @Column("prop1") 32 | private String nickName; 33 | private String email; 34 | @ReadOnly 35 | private Timestamp createTime; 36 | 37 | @JoinedBy("id=userId") 38 | private List devices; 39 | 40 | // Supposed to be empty. 41 | @JoinedBy("id=userId, firstName=model") 42 | private Device devices2; 43 | 44 | @JoinedBy("id=userId") 45 | private Address address; 46 | 47 | @JoinedBy({ "id=userId", "lastName=street" }) 48 | private List
address2; 49 | } -------------------------------------------------------------------------------- /samples/userSqlMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | select * from user where id = ? 4 | -------------------------------------------------------------------------------- /schema/DataSource.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Data source schema. Copyright 2015, Haiyang Li. All rights reserved. 7 | 8 | 9 | 10 | 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 | 79 | 80 | 81 | 82 | 83 | 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 | -------------------------------------------------------------------------------- /schema/SQLMapper.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Schema for pre-defined SQL in xml file. Copyright 2015, Haiyang Li. All rights reserved. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/DBProductInfo.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; 17 | 18 | public record DBProductInfo(String productName, String productVersion, DBVersion version) { // NOSONAR 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/DBSequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.landawn.abacus.jdbc; 16 | 17 | import java.sql.Connection; 18 | import java.sql.SQLException; 19 | import java.sql.Timestamp; 20 | import java.util.concurrent.atomic.AtomicLong; 21 | 22 | import javax.sql.DataSource; 23 | 24 | import com.landawn.abacus.exception.UncheckedSQLException; 25 | import com.landawn.abacus.logging.Logger; 26 | import com.landawn.abacus.logging.LoggerFactory; 27 | import com.landawn.abacus.util.Dates; 28 | import com.landawn.abacus.util.Dates.DateUtil; 29 | import com.landawn.abacus.util.Strings; 30 | 31 | // TODO: Auto-generated Javadoc 32 | /** 33 | * Supports global sequence by db table. 34 | * 35 | */ 36 | public final class DBSequence { 37 | 38 | private static final Logger logger = LoggerFactory.getLogger(DBSequence.class); 39 | 40 | private final DataSource ds; 41 | 42 | private final String seqName; 43 | 44 | private int seqBufferSize; 45 | 46 | private final String querySQL; 47 | 48 | private final String updateSQL; 49 | 50 | private final String resetSQL; 51 | 52 | private final AtomicLong lowSeqId; 53 | 54 | private final AtomicLong highSeqId; 55 | 56 | DBSequence(final DataSource ds, final String tableName, final String seqName, final long startVal, final int seqBufferSize) { 57 | this.ds = ds; 58 | this.seqName = seqName; 59 | this.seqBufferSize = seqBufferSize; 60 | 61 | if (Strings.isEmpty(tableName)) { 62 | throw new IllegalArgumentException("Table name can't be null or empty"); 63 | } 64 | 65 | if (Strings.isEmpty(seqName)) { 66 | throw new IllegalArgumentException("Sequence name can't be null or empty"); 67 | } 68 | 69 | if (startVal < 0) { 70 | throw new IllegalArgumentException("startVal can't be negative"); 71 | } 72 | 73 | if (seqBufferSize <= 0) { 74 | throw new IllegalArgumentException("startVal must be greater than 0"); 75 | } 76 | 77 | querySQL = "SELECT next_val FROM " + tableName + " WHERE seq_name = ?"; //NOSONAR 78 | updateSQL = "UPDATE " + tableName + " SET next_val = ?, update_time = ? WHERE next_val = ? AND seq_name = ?"; //NOSONAR 79 | resetSQL = "UPDATE " + tableName + " SET next_val = ?, update_time = ? WHERE seq_name = ?"; //NOSONAR 80 | lowSeqId = new AtomicLong(startVal); 81 | highSeqId = new AtomicLong(startVal); 82 | 83 | final String schema = "CREATE TABLE " + tableName 84 | + "(seq_name VARCHAR(64), next_val BIGINT, update_time TIMESTAMP NOT NULL, create_time TIMESTAMP NOT NULL, UNIQUE (seq_name))"; 85 | 86 | final Connection conn = JdbcUtil.getConnection(ds); 87 | 88 | try { //NOSONAR 89 | if (!JdbcUtil.doesTableExist(conn, tableName)) { 90 | try { //NOSONAR 91 | JdbcUtil.createTableIfNotExists(conn, tableName, schema); 92 | } catch (final Exception e) { 93 | if (logger.isWarnEnabled()) { 94 | logger.warn("Failed to create table: " + tableName); 95 | } 96 | } 97 | 98 | if (!JdbcUtil.doesTableExist(conn, tableName)) { 99 | throw new RuntimeException("Failed to create table: " + tableName); 100 | } 101 | } 102 | 103 | final Timestamp now = Dates.currentTimestamp(); 104 | 105 | if (JdbcUtil.prepareQuery(conn, "SELECT 1 FROM " + tableName + " WHERE seq_name = ?").setString(1, seqName).queryForInt().orElse(0) < 1) { 106 | try { //NOSONAR 107 | JdbcUtil.executeUpdate(conn, "INSERT INTO " + tableName + "(seq_name, next_val, update_time, create_time) VALUES (?, ?, ?, ?)", seqName, 108 | startVal, now, now); 109 | } catch (final Exception e) { 110 | if (logger.isWarnEnabled()) { 111 | logger.warn("Failed to initialize sequence: " + seqName + " within table: " + tableName); 112 | } 113 | } 114 | } 115 | 116 | JdbcUtil.executeUpdate(conn, "UPDATE " + tableName + " SET next_val = ?, update_time = ? WHERE seq_name = ? AND next_val < ?", startVal, now, 117 | seqName, startVal); 118 | 119 | if (JdbcUtil.prepareQuery(conn, "SELECT next_val FROM " + tableName + " WHERE seq_name = ?") 120 | .setString(1, seqName) 121 | .queryForLong() 122 | .orElse(0) < startVal) { 123 | throw new RuntimeException("Failed to initialize sequence: " + seqName + " within table: " + tableName); 124 | } 125 | } catch (final SQLException e) { 126 | throw new UncheckedSQLException(e); 127 | } finally { 128 | JdbcUtil.releaseConnection(conn, ds); 129 | } 130 | } 131 | 132 | /** 133 | * Retrieves the next value in the sequence. 134 | * This method is synchronized on the sequence name to ensure thread safety. 135 | * If the current low sequence ID is greater than or equal to the high sequence ID, 136 | * it fetches the next batch of sequence IDs from the database. 137 | * 138 | * @return The next value in the sequence. 139 | * @throws UncheckedSQLException if a database access error occurs. 140 | */ 141 | public long nextVal() { 142 | synchronized (seqName) { //NOSONAR 143 | try { 144 | while (lowSeqId.get() >= highSeqId.get()) { 145 | //noinspection resource 146 | lowSeqId.set(JdbcUtil.prepareQuery(ds, querySQL).setString(1, seqName).queryForLong().orElse(0)); 147 | 148 | if (JdbcUtil.executeUpdate(ds, updateSQL, lowSeqId.get() + seqBufferSize, DateUtil.currentTimestamp(), lowSeqId.get(), seqName) > 0) { 149 | highSeqId.set(lowSeqId.get() + seqBufferSize); 150 | 151 | break; 152 | } 153 | } 154 | } catch (final SQLException e) { 155 | throw new UncheckedSQLException(e); 156 | } 157 | } 158 | 159 | return lowSeqId.getAndIncrement(); 160 | } 161 | 162 | /** 163 | * Resets the sequence to the specified start value and buffer size. 164 | * 165 | * @param startVal The new starting value for the sequence. 166 | * @param seqBufferSize The new buffer size for the sequence. 167 | */ 168 | @SuppressWarnings("hiding") 169 | public void reset(final long startVal, final int seqBufferSize) { 170 | this.seqBufferSize = seqBufferSize; 171 | 172 | try { 173 | JdbcUtil.executeUpdate(ds, resetSQL, startVal, DateUtil.currentTimestamp(), seqName); 174 | } catch (final SQLException e) { 175 | throw new UncheckedSQLException(e); 176 | } 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/DBVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, 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 com.landawn.abacus.util.Strings; 20 | 21 | public enum DBVersion { 22 | 23 | H2, 24 | HSQLDB, 25 | /** The mysql 5 5. */ 26 | MYSQL_5_5, 27 | /** The mysql 5 6. */ 28 | MYSQL_5_6, 29 | /** The mysql 5 7. */ 30 | MYSQL_5_7, 31 | /** The mysql 5 8. */ 32 | MYSQL_5_8, 33 | /** The mysql 5 9. */ 34 | MYSQL_5_9, 35 | /** The mysql 6. */ 36 | MYSQL_6, 37 | /** The mysql 7. */ 38 | MYSQL_7, 39 | /** The mysql 8. */ 40 | MYSQL_8, 41 | /** The mysql 9. */ 42 | MYSQL_9, 43 | /** The mysql 10. */ 44 | MYSQL_10, 45 | MYSQL_OTHERS, 46 | /** The postgresql 9 2. */ 47 | // 48 | POSTGRESQL_9_2, 49 | /** The postgresql 9 3. */ 50 | POSTGRESQL_9_3, 51 | /** The postgresql 9 4. */ 52 | POSTGRESQL_9_4, 53 | /** The postgresql 9 5. */ 54 | POSTGRESQL_9_5, 55 | /** The postgresql 9 6. */ 56 | POSTGRESQL_9_6, 57 | /** The postgresql 10. */ 58 | POSTGRESQL_10, 59 | /** The postgresql 11. */ 60 | POSTGRESQL_11, 61 | /** The postgresql 12. */ 62 | POSTGRESQL_12, 63 | POSTGRESQL_OTHERS, 64 | // 65 | ORACLE, 66 | DB2, 67 | SQL_SERVER, 68 | OTHERS; 69 | 70 | /** 71 | * 72 | * 73 | * @return 74 | */ 75 | public boolean isMySQL() { 76 | return Strings.startsWithIgnoreCase(name(), "mysql"); 77 | } 78 | 79 | /** 80 | * 81 | * 82 | * @return 83 | */ 84 | public boolean isPostgreSQL() { 85 | return Strings.startsWithIgnoreCase(name(), "postgresql"); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/EmptyHandler.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; 17 | 18 | import com.landawn.abacus.annotation.Internal; 19 | import com.landawn.abacus.jdbc.dao.Dao; 20 | 21 | @Internal 22 | @SuppressWarnings("rawtypes") 23 | public final class EmptyHandler implements Jdbc.Handler { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/FetchDirection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.landawn.abacus.jdbc; 16 | 17 | import java.sql.ResultSet; 18 | 19 | /** 20 | * The Enum FetchDirection. 21 | */ 22 | public enum FetchDirection { 23 | 24 | FORWARD(ResultSet.FETCH_FORWARD), REVERSE(ResultSet.FETCH_REVERSE), UNKNOWN(ResultSet.FETCH_UNKNOWN); 25 | 26 | final int intValue; 27 | 28 | FetchDirection(final int intValue) { 29 | this.intValue = intValue; 30 | } 31 | 32 | /** 33 | * 34 | * @param intValue 35 | * @return 36 | */ 37 | public static FetchDirection valueOf(final int intValue) { 38 | switch (intValue) { 39 | case ResultSet.FETCH_FORWARD: 40 | return FORWARD; 41 | 42 | case ResultSet.FETCH_REVERSE: 43 | return REVERSE; 44 | 45 | case ResultSet.FETCH_UNKNOWN: 46 | return UNKNOWN; 47 | 48 | default: 49 | throw new IllegalArgumentException("No FetchDirection mapping to int value: " + intValue); 50 | 51 | } 52 | } 53 | 54 | /** 55 | * 56 | * 57 | * @return 58 | */ 59 | public int intValue() { 60 | return intValue; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/IsolationLevel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.landawn.abacus.jdbc; 16 | 17 | import java.sql.Connection; 18 | 19 | // TODO: Auto-generated Javadoc 20 | /** 21 | * The Enum IsolationLevel. 22 | * 23 | * @see http://docs.oracle.com/javase/tutorial/jdbc/basics/transactions.html 24 | */ 25 | public enum IsolationLevel { 26 | /** 27 | * Field DEFAULT. No {@code Connection.setTransactionIsolation(...)} will be called to set transaction isolation 28 | * level. 29 | */ 30 | DEFAULT(-1), 31 | 32 | /** 33 | * Field NONE. 34 | * @deprecated 35 | */ 36 | NONE(Connection.TRANSACTION_NONE), 37 | 38 | /** 39 | * Field READ_UNCOMMITTED. 40 | */ 41 | READ_UNCOMMITTED(Connection.TRANSACTION_READ_UNCOMMITTED), 42 | 43 | /** 44 | * Field READ_COMMITTED. 45 | */ 46 | READ_COMMITTED(Connection.TRANSACTION_READ_COMMITTED), 47 | 48 | /** 49 | * Field REPEATABLE_READ. 50 | */ 51 | REPEATABLE_READ(Connection.TRANSACTION_REPEATABLE_READ), 52 | 53 | /** 54 | * Field SERIALIZABLE. 55 | */ 56 | SERIALIZABLE(Connection.TRANSACTION_SERIALIZABLE); 57 | 58 | /** 59 | * Field intValue. 60 | */ 61 | private final int intValue; 62 | 63 | /** 64 | * 65 | * @param intValue 66 | */ 67 | IsolationLevel(final int intValue) { 68 | this.intValue = intValue; 69 | } 70 | 71 | /** 72 | * 73 | * @return int 74 | */ 75 | public int intValue() { 76 | return intValue; 77 | } 78 | 79 | /** 80 | * 81 | * @param intValue 82 | * @return IsolationLevel 83 | */ 84 | public static IsolationLevel valueOf(final int intValue) { 85 | switch (intValue) { 86 | case -1: 87 | return DEFAULT; 88 | 89 | case Connection.TRANSACTION_NONE: 90 | return NONE; 91 | 92 | case Connection.TRANSACTION_READ_UNCOMMITTED: 93 | return READ_UNCOMMITTED; 94 | 95 | case Connection.TRANSACTION_READ_COMMITTED: 96 | return READ_COMMITTED; 97 | 98 | case Connection.TRANSACTION_REPEATABLE_READ: 99 | return REPEATABLE_READ; 100 | 101 | case Connection.TRANSACTION_SERIALIZABLE: 102 | return SERIALIZABLE; 103 | 104 | default: 105 | throw new IllegalArgumentException("Invalid isolation level value: " + intValue + "."); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/JdbcSettings.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; 17 | 18 | //Archive for history. Replaced b PreparedQuery and Dao. 19 | final class JdbcSettings { 20 | 21 | private JdbcSettings() { 22 | // no use. 23 | } 24 | 25 | // public static final String DEFAULT_GENERATED_ID_PROP_NAME = "id"; 26 | // 27 | // public static final int DEFAULT_BATCH_SIZE = JdbcUtil.DEFAULT_BATCH_SIZE; 28 | // 29 | // public static final int DEFAULT_NO_GENERATED_KEYS = Statement.NO_GENERATED_KEYS; 30 | // 31 | // public static final int DEFAULT_FETCH_DIRECTION = ResultSet.FETCH_FORWARD; 32 | // 33 | // public static final int DEFAULT_RESULT_SET_TYPE = ResultSet.TYPE_FORWARD_ONLY; 34 | // 35 | // public static final int DEFAULT_RESULT_SET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY; 36 | // 37 | // public static final int DEFAULT_RESULT_SET_HOLDABILITY = ResultSet.HOLD_CURSORS_OVER_COMMIT; 38 | // 39 | // private boolean logSQL = false; 40 | // 41 | // private int batchSize = -1; 42 | // 43 | // private int queryTimeout = -1; 44 | // 45 | // private boolean autoGeneratedKeys = false; 46 | // 47 | // private int[] returnedColumnIndexes = null; 48 | // 49 | // private String[] returnedColumnNames = null; 50 | // 51 | // private int maxRows = -1; 52 | // 53 | // private int maxFieldSize = -1; 54 | // 55 | // private int fetchSize = -1; 56 | // 57 | // private int fetchDirection = -1; 58 | // 59 | // private int resultSetType = -1; 60 | // 61 | // private int resultSetConcurrency = -1; 62 | // 63 | // private int resultSetHoldability = -1; 64 | // 65 | // private boolean queryInParallel = false; 66 | // 67 | // private IsolationLevel isolationLevel = null; 68 | // 69 | // @Getter(value = AccessLevel.NONE) 70 | // @Setter(value = AccessLevel.NONE) 71 | // @EqualsAndHashCode.Exclude 72 | // @ToString.Exclude 73 | // private boolean noTransactionForStream = false; 74 | // 75 | // @Getter(value = AccessLevel.NONE) 76 | // @Setter(value = AccessLevel.NONE) 77 | // @EqualsAndHashCode.Exclude 78 | // @ToString.Exclude 79 | // private boolean isFrozen = false; 80 | // 81 | // /** 82 | // * 83 | // * @return 84 | // */ 85 | // public static JdbcSettings create() { 86 | // return new JdbcSettings(); 87 | // } 88 | // 89 | // /** 90 | // * 91 | // * @return 92 | // */ 93 | // public JdbcSettings copy() { 94 | // JdbcSettings copy = new JdbcSettings(); 95 | // copy.logSQL = this.logSQL; 96 | // copy.batchSize = this.batchSize; 97 | // copy.queryTimeout = this.queryTimeout; 98 | // copy.autoGeneratedKeys = this.autoGeneratedKeys; 99 | // copy.returnedColumnIndexes = (this.returnedColumnIndexes == null) ? null : N.copyOf(this.returnedColumnIndexes, this.returnedColumnIndexes.length); 100 | // copy.returnedColumnNames = (this.returnedColumnNames == null) ? null : N.copyOf(this.returnedColumnNames, this.returnedColumnNames.length); 101 | // copy.maxRows = this.maxRows; 102 | // copy.maxFieldSize = this.maxFieldSize; 103 | // copy.fetchSize = this.fetchSize; 104 | // copy.fetchDirection = this.fetchDirection; 105 | // copy.resultSetType = this.resultSetType; 106 | // copy.resultSetConcurrency = this.resultSetConcurrency; 107 | // copy.resultSetHoldability = this.resultSetHoldability; 108 | // copy.queryInParallel = this.queryInParallel; 109 | // copy.isolationLevel = this.isolationLevel; 110 | // copy.noTransactionForStream = this.noTransactionForStream; 111 | // 112 | // return copy; 113 | // } 114 | // 115 | // /** 116 | // * Stream transaction independent. 117 | // * 118 | // * @return true, if successful 119 | // */ 120 | // boolean noTransactionForStream() { 121 | // return noTransactionForStream; 122 | // } 123 | // 124 | // /** 125 | // * {@code noTransactionForStream = true} means the query executed by {@code stream/streamAll(...)} methods won't be in any transaction(using connection started by transaction), even the {@code stream/streamAll(...)} methods are invoked inside of a transaction block. 126 | // * 127 | // * @param noTransactionForStream 128 | // * @return 129 | // */ 130 | // JdbcSettings setNoTransactionForStream(final boolean noTransactionForStream) { 131 | // assertNotFrozen(); 132 | // 133 | // this.noTransactionForStream = noTransactionForStream; 134 | // 135 | // return this; 136 | // } 137 | // 138 | // /** 139 | // * Freeze. 140 | // */ 141 | // void freeze() { 142 | // isFrozen = true; 143 | // } 144 | // 145 | // /** 146 | // * Assert not frozen. 147 | // */ 148 | // void assertNotFrozen() { 149 | // if (isFrozen) { 150 | // throw new RuntimeException("It's finalized. No change is allowed"); 151 | // } 152 | // } 153 | } 154 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/OP.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; 17 | 18 | /** 19 | * 20 | * Refer to the operations in {@code AbstractQuery} 21 | * 22 | */ 23 | public enum OP { 24 | exists, 25 | findOnlyOne, 26 | findFirst, 27 | list, 28 | 29 | /** 30 | * @deprecated generally it's unnecessary to specify the {@code "op = OP.query"} in {@code Select/NamedSelect}. 31 | */ 32 | query, 33 | 34 | /** 35 | * 36 | * @deprecated generally it's unnecessary to specify the {@code "op = OP.stream"} in {@code Select/NamedSelect}. 37 | */ 38 | stream, 39 | 40 | queryForSingle, 41 | 42 | queryForUnique, 43 | 44 | /** 45 | * Mostly it's for {@code @Call} to retrieve all the {@code ResultSets} returned from the executed procedure by {@code listAll/listAllAndGetOutParameters}. 46 | */ 47 | listAll, 48 | 49 | /** 50 | * Mostly it's for {@code @Call} to retrieve all the {@code ResultSets} returned from the executed procedure by {@code queryAll/queryAllAndGetOutParameters}. 51 | */ 52 | queryAll, 53 | 54 | /** 55 | * Mostly it's for {@code @Call} to retrieve all the {@code ResultSets} returned from the executed procedure by {@code streamAll}. 56 | */ 57 | streamAll, 58 | 59 | /** 60 | * Mostly it's for {@code @Call} to execute the target procedure and get out parameters by {@code executeAndGetOutParameters}. 61 | */ 62 | executeAndGetOutParameters, 63 | 64 | update, 65 | 66 | largeUpdate, 67 | 68 | /* batchUpdate,*/ 69 | 70 | DEFAULT 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/OnDeleteAction.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 | 17 | package com.landawn.abacus.jdbc; 18 | 19 | import com.landawn.abacus.annotation.Beta; 20 | 21 | /** 22 | * It should be defined and done in DB server side. 23 | * @deprecated won't and should not be implemented. 24 | */ 25 | @Beta 26 | @Deprecated 27 | public enum OnDeleteAction { 28 | /** 29 | * Field NO_ACTION. 30 | */ 31 | NO_ACTION(0), 32 | /** 33 | * Field SET_NULL. 34 | */ 35 | SET_NULL(1), 36 | /** 37 | * Field CASCADE. 38 | */ 39 | CASCADE(2); 40 | 41 | /** 42 | * Field intValue. 43 | */ 44 | private final int intValue; 45 | 46 | OnDeleteAction(final int intValue) { 47 | this.intValue = intValue; 48 | } 49 | 50 | /** 51 | * 52 | * @return int 53 | */ 54 | public int value() { 55 | return intValue; 56 | } 57 | 58 | /** 59 | * 60 | * @param name 61 | * @return ConstraintType 62 | */ 63 | public static OnDeleteAction get(final String name) { 64 | if ("noAction".equalsIgnoreCase(name)) { 65 | return NO_ACTION; 66 | } else if ("setNull".equalsIgnoreCase(name)) { 67 | return SET_NULL; 68 | } else if ("cascade".equalsIgnoreCase(name)) { 69 | return CASCADE; 70 | } else { 71 | throw new IllegalArgumentException("Invalid CascadeType value[" + name + "]. "); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/PreparedQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, 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 java.sql.PreparedStatement; 20 | 21 | /** 22 | * The backed {@code PreparedStatement/CallableStatement} will be closed by default 23 | * after any execution methods (which will trigger the backed {@code PreparedStatement/CallableStatement} to be executed, 24 | * for example, get/query/queryForInt/Long/../findFirst/findOnlyOne/list/execute/...). 25 | * Except the {@code 'closeAfterExecution'} flag is set to {@code false} by calling {@code #closeAfterExecution(false)}. 26 | * 27 | *
28 | * Generally, don't cache or reuse the instance of this class, 29 | * except the {@code 'closeAfterExecution'} flag is set to {@code false} by calling {@code #closeAfterExecution(false)}. 30 | * 31 | *
32 | * The {@code ResultSet} returned by query will always be closed after execution, even {@code 'closeAfterExecution'} flag is set to {@code false}. 33 | * 34 | *
35 | * Remember: parameter/column index in {@code PreparedStatement/ResultSet} starts from 1, not 0. 36 | * 37 | * 38 | * @see {@link com.landawn.abacus.annotation.ReadOnly} 39 | * @see {@link com.landawn.abacus.annotation.ReadOnlyId} 40 | * @see {@link com.landawn.abacus.annotation.NonUpdatable} 41 | * @see {@link com.landawn.abacus.annotation.Transient} 42 | * @see {@link com.landawn.abacus.annotation.Table} 43 | * @see {@link com.landawn.abacus.annotation.Column} 44 | * 45 | * @see Connection 46 | * @see Statement 47 | * @see PreparedStatement 48 | * @see ResultSet 49 | */ 50 | public final class PreparedQuery extends AbstractQuery { 51 | 52 | PreparedQuery(final PreparedStatement stmt) { 53 | super(stmt); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/Propagation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2019 the original author or authors. 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; 17 | 18 | public enum Propagation { 19 | 20 | /** 21 | * Support a current transaction, create a new one if none exists. 22 | *

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 44 | * @param requiredType 45 | * @return 46 | */ 47 | public T getBean(final Class requiredType) { 48 | return appContext == null ? null : appContext.getBean(requiredType); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/SqlLogConfig.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; 17 | 18 | final class SqlLogConfig { 19 | boolean isEnabled; 20 | int maxSqlLogLength; 21 | long minExecutionTimeForSqlPerfLog; 22 | 23 | SqlLogConfig(final boolean isEnabled, final int maxSqlLogLength) { 24 | this.isEnabled = isEnabled; 25 | this.maxSqlLogLength = maxSqlLogLength <= 0 ? JdbcUtil.DEFAULT_MAX_SQL_LOG_LENGTH : maxSqlLogLength; 26 | minExecutionTimeForSqlPerfLog = Long.MAX_VALUE; 27 | } 28 | 29 | SqlLogConfig(final long minExecutionTimeForSqlPerfLog, final int maxSqlLogLength) { 30 | this.minExecutionTimeForSqlPerfLog = minExecutionTimeForSqlPerfLog; 31 | this.maxSqlLogLength = maxSqlLogLength <= 0 ? JdbcUtil.DEFAULT_MAX_SQL_LOG_LENGTH : maxSqlLogLength; 32 | isEnabled = false; 33 | } 34 | 35 | void set(final boolean isEnabled, final int maxSqlLogLength) { 36 | this.isEnabled = isEnabled; 37 | this.maxSqlLogLength = maxSqlLogLength <= 0 ? JdbcUtil.DEFAULT_MAX_SQL_LOG_LENGTH : maxSqlLogLength; 38 | } 39 | 40 | void set(final long minExecutionTimeForSqlPerfLog, final int maxSqlLogLength) { 41 | this.minExecutionTimeForSqlPerfLog = minExecutionTimeForSqlPerfLog; 42 | this.maxSqlLogLength = maxSqlLogLength <= 0 ? JdbcUtil.DEFAULT_MAX_SQL_LOG_LENGTH : maxSqlLogLength; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/Transaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.landawn.abacus.jdbc; 16 | 17 | import com.landawn.abacus.exception.UncheckedSQLException; 18 | 19 | // TODO: Auto-generated Javadoc 20 | /** 21 | * 22 | */ 23 | public interface Transaction { 24 | 25 | /** 26 | * Returns the unique identifier of the transaction. 27 | * 28 | * @return the unique identifier of the transaction. 29 | */ 30 | String id(); 31 | 32 | /** 33 | * Returns the isolation level of the transaction. 34 | * 35 | * @return the isolation level of the transaction. 36 | */ 37 | IsolationLevel isolationLevel(); 38 | 39 | /** 40 | * Returns the current status of the transaction. 41 | * 42 | * @return the current status of the transaction. 43 | */ 44 | Status status(); 45 | 46 | /** 47 | * Checks if the transaction is active. 48 | * 49 | * @return {@code true} if the transaction is active, {@code false} otherwise. 50 | */ 51 | boolean isActive(); 52 | 53 | /** 54 | * Commits the current transaction. 55 | * 56 | * @throws UncheckedSQLException if an SQL error occurs during the commit. 57 | */ 58 | void commit() throws UncheckedSQLException; 59 | 60 | // /** 61 | // * Commits the current transaction and executes the specified action after the commit. 62 | // * 63 | // * @param actionAfterCommit the action to be executed after the current transaction is committed successfully. 64 | // * @throws UncheckedSQLException if an SQL error occurs during the commit. 65 | // */ 66 | // @Beta 67 | // void commit(Runnable actionAfterCommit) throws UncheckedSQLException; 68 | 69 | /** 70 | * Rolls back the current transaction. 71 | * 72 | * @throws UncheckedSQLException the unchecked SQL exception 73 | */ 74 | void rollback() throws UncheckedSQLException; 75 | 76 | // /** 77 | // * Rolls back the current transaction and execute the specified action after the rollback. 78 | // * 79 | // * @param actionAfterRollback the action to be executed after the current transaction is rolled back, not successfully or not. 80 | // * @throws UncheckedSQLException if an SQL error occurs during the rollback. 81 | // */ 82 | // @Beta 83 | // void rollback(Runnable actionAfterRollback) throws UncheckedSQLException; 84 | 85 | /** 86 | * Rolls back the transaction if it has not been committed successfully. 87 | * 88 | * @throws UncheckedSQLException if an SQL error occurs during the rollback. 89 | */ 90 | void rollbackIfNotCommitted() throws UncheckedSQLException; 91 | 92 | /** 93 | * The Enum Status. 94 | * 95 | * @version $Revision: 0.8 $ 07/01/15 96 | */ 97 | enum Status { 98 | /** 99 | * Field ACTIVE. 100 | */ 101 | ACTIVE, 102 | /** 103 | * Field MARKED_ROLLBACK. 104 | */ 105 | MARKED_ROLLBACK, 106 | /** 107 | * Field COMMITTED. 108 | */ 109 | COMMITTED, 110 | /** 111 | * Field FAILED_COMMIT. 112 | */ 113 | FAILED_COMMIT, 114 | /** 115 | * Field ROLLED_BACK. 116 | */ 117 | ROLLED_BACK, 118 | /** 119 | * Field FAILED_ROLLBACK. 120 | */ 121 | FAILED_ROLLBACK 122 | } 123 | 124 | /** 125 | * The Enum Action. 126 | * 127 | */ 128 | enum Action { 129 | 130 | /** The commit. */ 131 | COMMIT, 132 | 133 | /** The rollback. */ 134 | ROLLBACK 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/Bind.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 | * The Interface Bind. 25 | */ 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target(ElementType.PARAMETER) 28 | public @interface Bind { 29 | 30 | /** 31 | * 32 | * 33 | * @return 34 | */ 35 | String value() default ""; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/BindList.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 | /** 26 | * The Interface BindList. 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.PARAMETER) 30 | public @interface BindList { 31 | 32 | /** 33 | * 34 | * 35 | * @return 36 | */ 37 | String value() default ""; 38 | 39 | /** 40 | * 41 | * @return 42 | */ 43 | @Beta 44 | String prefixForNonEmpty() default ""; // Should use @Define when prefixForNonEmpty or suffixForNonEmpty is used? 45 | 46 | /** 47 | * 48 | * @return 49 | */ 50 | @Beta 51 | String suffixForNonEmpty() default ""; // Should use @Define when prefixForNonEmpty or suffixForNonEmpty is used? 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/Cache.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.Jdbc; 25 | import com.landawn.abacus.jdbc.Jdbc.DaoCache; 26 | import com.landawn.abacus.jdbc.JdbcUtil; 27 | 28 | // TODO: First of all, it's a bad idea to implement cache in DAL layer?! and how if not? 29 | /** 30 | * Mostly, it's used for static tables. 31 | */ 32 | @Beta 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Target(value = { ElementType.TYPE }) 35 | public @interface Cache { 36 | 37 | /** 38 | * 39 | * 40 | * @return 41 | */ 42 | int capacity() default JdbcUtil.DEFAULT_BATCH_SIZE; 43 | 44 | /** 45 | * 46 | * 47 | * @return 48 | */ 49 | long evictDelay() default JdbcUtil.DEFAULT_CACHE_EVICT_DELAY; // unit milliseconds. 50 | 51 | /** 52 | * The implementation of {@code DaoCache}. It must have a public constructor with type: {@code (int capacity, long evictDelay)}. 53 | * 54 | * @return 55 | */ 56 | Class impl() default Jdbc.DefaultDaoCache.class; //NOSONAR 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/CacheResult.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 | 26 | @Beta 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(value = { ElementType.METHOD, ElementType.TYPE }) 29 | public @interface CacheResult { 30 | /** 31 | * Flag to identity if {@code CacheResult} is disabled. 32 | * @return 33 | */ 34 | boolean disabled() default false; 35 | 36 | /** 37 | * 38 | * @return 39 | */ 40 | long liveTime() default JdbcUtil.DEFAULT_CACHE_LIVE_TIME; // unit milliseconds. 41 | 42 | /** 43 | * 44 | * @return 45 | */ 46 | long maxIdleTime() default JdbcUtil.DEFAULT_CACHE_MAX_IDLE_TIME; // unit milliseconds. 47 | 48 | /** 49 | * Minimum required size to cache a query result if the return type is {@code Collection} or {@code DataSet}. 50 | * This setting will be ignored if the return types are not {@code Collection} or {@code DataSet}. 51 | * 52 | * @return 53 | */ 54 | int minSize() default 0; // for list/DataSet. 55 | 56 | /** 57 | * If the query result isn't cached if it's size is bigger than {@code maxSize} if the return type is {@code Collection} or {@code DataSet}. 58 | * This setting will be ignored if the return types are not {@code Collection} or {@code DataSet}. 59 | * 60 | * @return 61 | */ 62 | int maxSize() default Integer.MAX_VALUE; // for list/DataSet. 63 | 64 | /** 65 | * It's used to copy/clone the result when save result to cache or fetch result from cache. 66 | * It can be set to {@code "none", "kryo" or "json"}. 67 | * 68 | * @return 69 | * @see kryo 70 | */ 71 | String transfer() default "none"; 72 | 73 | // /** 74 | // * If it's set to true, the cached result won't be removed by method annotated by {@code RefreshCache}. 75 | // * 76 | // * @return 77 | // */ 78 | // boolean isStaticData() default false; 79 | 80 | /** 81 | * Those conditions (by contains ignore case or regular expression match) will be joined by {@code OR}, not {@code AND}. 82 | * It's only applied if target of annotation {@code CacheResult} is {@code Type}, and will be ignored if target is method. 83 | * 84 | * @return 85 | */ 86 | String[] filter() default { "query", "queryFor", "list", "get", "batchGet", "find", "findFirst", "findOnlyOne", "exist", "notExist", "count" }; 87 | 88 | // TODO: second, what will key be like?: {methodName=[args]} -> JSON or kryo? 89 | // KeyGenerator keyGenerator() default KeyGenerator.JSON; KeyGenerator.JSON/KRYO; 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/Call.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.OP; 24 | 25 | /** 26 | * The Interface Call. 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.METHOD) 30 | public @interface Call { 31 | 32 | /** 33 | * Use {@code sql} to specify attribute explicitly 34 | * 35 | * @return 36 | * @deprecated using {@code sql="call update_account(?)"} or {@code id="updateAccount"} for explicit call. 37 | */ 38 | @Deprecated 39 | String value() default ""; 40 | 41 | /** 42 | * 43 | * @return 44 | */ 45 | String sql() default ""; 46 | 47 | /** 48 | * 49 | * @return 50 | */ 51 | String id() default ""; // id defined SqlMapper 52 | 53 | /** 54 | * 55 | * @return 56 | */ 57 | int fetchSize() default -1; 58 | 59 | /** 60 | * Unit is seconds. 61 | * 62 | * @return 63 | */ 64 | int queryTimeout() default -1; 65 | 66 | /** 67 | * 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. 68 | * 69 | * @return 70 | */ 71 | boolean isSingleParameter() default false; 72 | 73 | /** 74 | * Set it to {@code true} if you want to retrieve all the {@code ResultSets} returned from the executed procedure by {@code queryAll/listAll/streamAll}. 75 | * It is {@code false} by default. The reason is all the query methods extended from {@code AbstractQuery} only retrieve the first {@code ResultSet}. 76 | * 77 | * @return 78 | */ 79 | OP op() default OP.DEFAULT; 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/Config.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 Config { 26 | /** 27 | * Single query method includes: queryForSingleXxx/queryForUniqueResult/findFirst/findOnlyOne/exists/count... 28 | * 29 | * @return 30 | */ 31 | boolean addLimitForSingleQuery() default false; 32 | 33 | /** 34 | * flag to call {@code generateId} for {@code CrudDao.insert(T entity), CrudDao.batchInsert(Collection entities)} if the ids are not set or set with default value. 35 | * 36 | * @return 37 | */ 38 | boolean callGenerateIdForInsertIfIdNotSet() default false; 39 | 40 | /** 41 | * flag to call {@code generateId} for {@code CrudDao.insert(String sql, T entity), CrudDao.batchInsert(String sql, Collection entities)} if the ids are not set or set with default value. 42 | * 43 | * 44 | * @return 45 | */ 46 | boolean callGenerateIdForInsertWithSqlIfIdNotSet() default false; 47 | 48 | /** 49 | * 50 | * @return 51 | */ 52 | boolean allowJoiningByNullOrDefaultValue() default false; 53 | 54 | // // why do we need this? 55 | // boolean excludePrepareQueryMethodsFromNonDBOperation() default false; 56 | 57 | /** 58 | * 59 | * @return 60 | */ 61 | boolean fetchColumnByEntityClassForDataSetQuery() default true; 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/Define.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 | * Replace the parts defined with format {@code {part}} in the SQL annotated to the method. 25 | * For example: 26 | *

27 | * 28 | * 29 | * @Select("SELECT first_name, last_name FROM {tableName} WHERE id = :id") 30 | *
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 | *
44 | *

45 | * 46 | */ 47 | @Retention(RetentionPolicy.RUNTIME) 48 | @Target(value = { ElementType.PARAMETER }) 49 | public @interface Define { 50 | 51 | /** 52 | * 53 | * 54 | * @return 55 | */ 56 | String value() default ""; 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/DefineList.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 | import java.util.Collection; 23 | 24 | /** 25 | * Defines a named attribute as a comma-separated {@link String} from the elements of the annotated array or {@link Collection} argument. 26 | * 27 | * @see Define 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target(value = { ElementType.PARAMETER }) 31 | public @interface DefineList { 32 | 33 | /** 34 | * 35 | * 36 | * @return 37 | */ 38 | String value() default ""; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/Delete.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 | 26 | /** 27 | * The Interface Delete. 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 Delete { 34 | 35 | /** 36 | * Use {@code sql} to specify attribute explicitly 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 | boolean isBatch() default false; 61 | 62 | /** 63 | * 64 | * @return 65 | */ 66 | int batchSize() default JdbcUtil.DEFAULT_BATCH_SIZE; 67 | 68 | /** 69 | * Unit is seconds. 70 | * 71 | * @return 72 | */ 73 | int queryTimeout() default -1; 74 | 75 | /** 76 | * 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. 77 | * 78 | * @return 79 | */ 80 | boolean isSingleParameter() default false; 81 | 82 | /** 83 | * 84 | * @return 85 | * @see Define 86 | * @see DefineList 87 | */ 88 | @Beta 89 | boolean hasDefineWithNamedParameter() default false; 90 | 91 | /** 92 | * Set named parameter {@code :now} to current system time if it's {@code true}. 93 | * 94 | * @return 95 | */ 96 | @Beta 97 | boolean timestamped() default false; 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/FetchColumnByEntityClass.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.METHOD }) 25 | public @interface FetchColumnByEntityClass { 26 | 27 | /** 28 | * 29 | * 30 | * @return 31 | */ 32 | boolean value() default true; 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/Handler.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 | 24 | import com.landawn.abacus.annotation.Beta; 25 | import com.landawn.abacus.jdbc.EmptyHandler; 26 | import com.landawn.abacus.jdbc.Jdbc; 27 | import com.landawn.abacus.jdbc.dao.Dao; 28 | 29 | @Beta 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target(value = { ElementType.METHOD, ElementType.TYPE }) 32 | @Repeatable(HandlerList.class) 33 | public @interface Handler { 34 | 35 | /** 36 | * 37 | * 38 | * @return 39 | */ 40 | String qualifier() default ""; 41 | 42 | /** 43 | * 44 | * 45 | * @return 46 | */ 47 | @SuppressWarnings("rawtypes") 48 | Class> type() default EmptyHandler.class; //NOSONAR 49 | 50 | /** 51 | * Those conditions (by contains ignore case or regular expression match) will be joined by {@code OR}, not {@code AND}. 52 | * It's only applied if target of annotation {@code Handler} is {@code Type}, and will be ignored if target is method. 53 | * 54 | * @return 55 | */ 56 | String[] filter() default { ".*" }; 57 | 58 | /** 59 | * This {@code Handler} will be ignored for the invoking from methods of the {@code Dao} if it's set to {@code true}. By default, it's {@code false}. 60 | * 61 | * @return 62 | */ 63 | boolean isForInvokeFromOutsideOfDaoOnly() default false; 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/HandlerList.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.METHOD, ElementType.TYPE }) 25 | public @interface HandlerList { 26 | 27 | /** 28 | * 29 | * 30 | * @return 31 | */ 32 | Handler[] value(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/Insert.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 | 26 | /** 27 | * The Interface Insert. 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 Insert { 34 | 35 | /** 36 | * Use {@code sql} to specify attribute explicitly 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 | boolean isBatch() default false; 61 | 62 | /** 63 | * 64 | * @return 65 | */ 66 | int batchSize() default JdbcUtil.DEFAULT_BATCH_SIZE; 67 | 68 | /** 69 | * Unit is seconds. 70 | * 71 | * @return 72 | */ 73 | int queryTimeout() default -1; 74 | 75 | /** 76 | * 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. 77 | * 78 | * @return 79 | */ 80 | boolean isSingleParameter() default false; 81 | 82 | /** 83 | * 84 | * @return 85 | * @see Define 86 | * @see DefineList 87 | */ 88 | @Beta 89 | boolean hasDefineWithNamedParameter() default false; 90 | 91 | /** 92 | * Set named parameter {@code :now} to current system time if it's {@code true}. 93 | * 94 | * @return 95 | */ 96 | @Beta 97 | boolean timestamped() default false; 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/MappedByKey.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 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | /** 26 | * The result will be merged by {@code keyName} and mapped to {@code map}. 27 | * 28 | * For example: 29 | *

30 | * 31 | * 32 | * @Select("SELECT id, first_name, last_name FROM user WHERE id in ({ids}") 33 | *
34 | * @MappedByKey("id") 35 | *
36 | * Map<Long, User> listUser(@BindList("ids") List ids) throws SQLException; 37 | * 38 | *
39 | *

40 | * 41 | */ 42 | @Retention(RetentionPolicy.RUNTIME) 43 | @Target(value = { ElementType.METHOD }) 44 | public @interface MappedByKey { 45 | 46 | /** 47 | * Use {@code keyName} to specify attribute explicitly 48 | * 49 | * @return 50 | * @deprecated using keyName="id" for explicit call. 51 | */ 52 | @Deprecated 53 | String value() default ""; 54 | 55 | /** 56 | * 57 | * 58 | * @return 59 | */ 60 | String keyName() default ""; 61 | 62 | /** 63 | * 64 | * 65 | * @return 66 | */ 67 | @SuppressWarnings("rawtypes") 68 | Class mapClass() default HashMap.class; 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/annotation/MergedById.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 | * For example: 25 | *

26 | * 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 | *
30 | * @MergedById 31 | *
32 | * List listUser(@BindList("ids") List ids) throws SQLException; 33 | * 34 | *
35 | *

36 | * 37 | */ 38 | @Retention(RetentionPolicy.RUNTIME) 39 | @Target(value = { ElementType.METHOD }) 40 | public @interface MergedById { 41 | 42 | /** 43 | * @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 | *
  • No {@code Handler} is applied to {@code non-db Operation}
  • 27 | *
  • No {@code sql/performance} log is applied to {@code non-db Operation}
  • 28 | *
  • No {@code Transaction} annotation is applied to {@code non-db Operation}
  • 29 | * 30 | *
    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> 27 | extends NoUpdateCrudDao, CrudDaoL { 28 | 29 | /** 30 | * 31 | * 32 | * @param propName 33 | * @param propValue 34 | * @param id 35 | * @return 36 | * @throws SQLException 37 | * @throws UnsupportedOperationException 38 | * @deprecated unsupported Operation 39 | */ 40 | @Deprecated 41 | @Override 42 | default int update(final String propName, final Object propValue, final long id) throws SQLException, UnsupportedOperationException { 43 | throw new UnsupportedOperationException(); 44 | } 45 | 46 | /** 47 | * 48 | * 49 | * @param updateProps 50 | * @param id 51 | * @return 52 | * @throws SQLException 53 | * @throws UnsupportedOperationException 54 | * @deprecated unsupported Operation 55 | */ 56 | @Deprecated 57 | @Override 58 | default int update(final Map updateProps, final long id) throws SQLException, UnsupportedOperationException { 59 | throw new UnsupportedOperationException(); 60 | } 61 | 62 | /** 63 | * 64 | * 65 | * @param id 66 | * @return 67 | * @throws SQLException 68 | * @throws UnsupportedOperationException 69 | * @deprecated unsupported Operation 70 | */ 71 | @Deprecated 72 | @Override 73 | default int deleteById(final long id) throws SQLException, UnsupportedOperationException { 74 | throw new UnsupportedOperationException(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/ReadOnlyCrudDao.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.Collection; 20 | import java.util.List; 21 | 22 | import com.landawn.abacus.annotation.Beta; 23 | import com.landawn.abacus.util.SQLBuilder; 24 | 25 | /** 26 | * Interface for a read-only Data Access Object (DAO). 27 | * 28 | * @param 29 | * @param 30 | * @param 31 | * @param 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> 38 | extends ReadOnlyDao, NoUpdateCrudDao { 39 | 40 | /** 41 | * 42 | * @param entityToInsert 43 | * @return 44 | * @throws SQLException 45 | * @throws UnsupportedOperationException 46 | * @deprecated unsupported Operation 47 | */ 48 | @Deprecated 49 | @Override 50 | default ID insert(final T entityToInsert) throws SQLException, UnsupportedOperationException { 51 | throw new UnsupportedOperationException(); 52 | } 53 | 54 | /** 55 | * 56 | * @param entityToInsert 57 | * @param propNamesToInsert 58 | * @return 59 | * @throws SQLException 60 | * @throws UnsupportedOperationException 61 | * @deprecated unsupported Operation 62 | */ 63 | @Deprecated 64 | @Override 65 | default ID insert(final T entityToInsert, final Collection propNamesToInsert) throws SQLException, UnsupportedOperationException { 66 | throw new UnsupportedOperationException(); 67 | } 68 | 69 | /** 70 | * 71 | * @param namedInsertSQL 72 | * @param entityToSave 73 | * @return 74 | * @throws SQLException 75 | * @throws UnsupportedOperationException 76 | * @deprecated unsupported Operation 77 | */ 78 | @Deprecated 79 | @Override 80 | default ID insert(final String namedInsertSQL, final T entityToSave) throws SQLException, UnsupportedOperationException { 81 | throw new UnsupportedOperationException(); 82 | } 83 | 84 | /** 85 | * 86 | * @param entities 87 | * @return 88 | * @throws SQLException 89 | * @throws UnsupportedOperationException 90 | * @deprecated unsupported Operation 91 | */ 92 | @Deprecated 93 | @Override 94 | default List batchInsert(final Collection entities) throws SQLException, UnsupportedOperationException { 95 | throw new UnsupportedOperationException(); 96 | } 97 | 98 | /** 99 | * 100 | * @param entities 101 | * @param batchSize 102 | * @return 103 | * @throws SQLException 104 | * @throws UnsupportedOperationException 105 | * @deprecated unsupported Operation 106 | */ 107 | @Deprecated 108 | @Override 109 | default List batchInsert(final Collection entities, final int batchSize) throws SQLException, UnsupportedOperationException { 110 | throw new UnsupportedOperationException(); 111 | } 112 | 113 | /** 114 | * 115 | * @param entities 116 | * @param propNamesToInsert 117 | * @return 118 | * @throws SQLException 119 | * @throws UnsupportedOperationException 120 | * @deprecated unsupported Operation 121 | */ 122 | @Deprecated 123 | @Override 124 | default List batchInsert(final Collection entities, final Collection propNamesToInsert) 125 | throws SQLException, UnsupportedOperationException { 126 | throw new UnsupportedOperationException(); 127 | } 128 | 129 | /** 130 | * 131 | * @param entities 132 | * @param propNamesToInsert 133 | * @param batchSize 134 | * @return 135 | * @throws SQLException 136 | * @throws UnsupportedOperationException 137 | * @deprecated unsupported Operation 138 | */ 139 | @Deprecated 140 | @Override 141 | default List batchInsert(final Collection entities, final Collection propNamesToInsert, final int batchSize) 142 | throws SQLException, UnsupportedOperationException { 143 | throw new UnsupportedOperationException(); 144 | } 145 | 146 | /** 147 | * 148 | * @param namedInsertSQL 149 | * @param entities 150 | * @return 151 | * @throws SQLException 152 | * @throws UnsupportedOperationException 153 | * @deprecated unsupported Operation 154 | */ 155 | @Deprecated 156 | @Override 157 | default List batchInsert(final String namedInsertSQL, final Collection entities) throws SQLException, UnsupportedOperationException { 158 | throw new UnsupportedOperationException(); 159 | } 160 | 161 | /** 162 | * 163 | * @param namedInsertSQL 164 | * @param entities 165 | * @param batchSize 166 | * @return 167 | * @throws SQLException 168 | * @throws UnsupportedOperationException 169 | * @deprecated unsupported Operation 170 | */ 171 | @Deprecated 172 | @Override 173 | default List batchInsert(final String namedInsertSQL, final Collection entities, final int batchSize) 174 | throws SQLException, UnsupportedOperationException { 175 | throw new UnsupportedOperationException(); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/ReadOnlyCrudDaoL.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 com.landawn.abacus.annotation.Beta; 19 | import com.landawn.abacus.util.SQLBuilder; 20 | 21 | @Beta 22 | public interface ReadOnlyCrudDaoL> 23 | extends ReadOnlyCrudDao, NoUpdateCrudDaoL { 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/ReadOnlyCrudJoinEntityHelper.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 com.landawn.abacus.util.SQLBuilder; 19 | 20 | public interface ReadOnlyCrudJoinEntityHelper> 21 | extends ReadOnlyJoinEntityHelper, CrudJoinEntityHelper { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/ReadOnlyCrudJoinEntityHelperL.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 com.landawn.abacus.util.SQLBuilder; 19 | 20 | /** 21 | * Interface for read-only operations with join entity support. 22 | * 23 | * @param the type of the entity 24 | * @param the type of the SQL builder 25 | * @param the type of the CRUD DAO 26 | */ 27 | public interface ReadOnlyCrudJoinEntityHelperL> 28 | extends ReadOnlyCrudJoinEntityHelper, CrudJoinEntityHelperL { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/UncheckedNoUpdateCrudDaoL.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.util.Map; 19 | 20 | import com.landawn.abacus.annotation.Beta; 21 | import com.landawn.abacus.exception.UncheckedSQLException; 22 | import com.landawn.abacus.util.SQLBuilder; 23 | 24 | @Beta 25 | public interface UncheckedNoUpdateCrudDaoL> 26 | extends UncheckedNoUpdateCrudDao, UncheckedCrudDaoL { 27 | 28 | /** 29 | * 30 | * 31 | * @param propName 32 | * @param propValue 33 | * @param id 34 | * @return 35 | * @throws UncheckedSQLException 36 | * @throws UnsupportedOperationException 37 | * @deprecated unsupported Operation 38 | */ 39 | @Deprecated 40 | @Override 41 | default int update(final String propName, final Object propValue, final long id) throws UncheckedSQLException, UnsupportedOperationException { 42 | throw new UnsupportedOperationException(); 43 | } 44 | 45 | /** 46 | * 47 | * 48 | * @param updateProps 49 | * @param id 50 | * @return 51 | * @throws UncheckedSQLException 52 | * @throws UnsupportedOperationException 53 | * @deprecated unsupported Operation 54 | */ 55 | @Deprecated 56 | @Override 57 | default int update(final Map updateProps, final long id) throws UncheckedSQLException, UnsupportedOperationException { 58 | throw new UnsupportedOperationException(); 59 | } 60 | 61 | /** 62 | * 63 | * 64 | * @param id 65 | * @return 66 | * @throws UncheckedSQLException 67 | * @throws UnsupportedOperationException 68 | * @deprecated unsupported Operation 69 | */ 70 | @Deprecated 71 | @Override 72 | default int deleteById(final long id) throws UncheckedSQLException, UnsupportedOperationException { 73 | throw new UnsupportedOperationException(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/UncheckedNoUpdateDao.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.util.Collection; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | import com.landawn.abacus.annotation.Beta; 23 | import com.landawn.abacus.condition.Condition; 24 | import com.landawn.abacus.exception.UncheckedSQLException; 25 | import com.landawn.abacus.util.SQLBuilder; 26 | 27 | /** 28 | * Interface for an unchecked Data Access Object (DAO) that does not support update operations. 29 | * Its methods throw {@code UncheckedSQLException} instead of {@code SQLException}. 30 | * 31 | * @param 32 | * @param {@code SQLBuilder} used to generate sql scripts. Only can be {@code SQLBuilder.PSC/PAC/PLC} 33 | * @param 34 | * @see com.landawn.abacus.condition.ConditionFactory 35 | * @see com.landawn.abacus.condition.ConditionFactory.CF 36 | */ 37 | @Beta 38 | public interface UncheckedNoUpdateDao> 39 | extends UncheckedDao, NoUpdateDao { 40 | 41 | /** 42 | * 43 | * 44 | * @param propName 45 | * @param propValue 46 | * @param cond 47 | * @return 48 | * @throws UncheckedSQLException the unchecked SQL exception 49 | * @throws UnsupportedOperationException 50 | * @deprecated unsupported Operation 51 | */ 52 | @Override 53 | @Deprecated 54 | default int update(final String propName, final Object propValue, final Condition cond) throws UncheckedSQLException, UnsupportedOperationException { 55 | throw new UnsupportedOperationException(); 56 | } 57 | 58 | /** 59 | * 60 | * @param updateProps 61 | * @param cond 62 | * @return 63 | * @throws UncheckedSQLException 64 | * @throws UnsupportedOperationException 65 | * @deprecated unsupported Operation 66 | */ 67 | @Deprecated 68 | @Override 69 | default int update(final Map updateProps, final Condition cond) throws UncheckedSQLException, UnsupportedOperationException { 70 | throw new UnsupportedOperationException(); 71 | } 72 | 73 | /** 74 | * @param entity 75 | * @param cond to verify if the record exists or not. 76 | * @return 77 | * @throws UncheckedSQLException 78 | * @throws UnsupportedOperationException 79 | * @deprecated unsupported Operation 80 | */ 81 | @Deprecated 82 | @Override 83 | default int update(final T entity, final Condition cond) throws UncheckedSQLException, UnsupportedOperationException { 84 | throw new UnsupportedOperationException(); 85 | } 86 | 87 | /** 88 | * 89 | * 90 | * @param entity 91 | * @param propNamesToUpdate 92 | * @param cond 93 | * @return 94 | * @throws UncheckedSQLException 95 | * @throws UnsupportedOperationException 96 | * @deprecated unsupported Operation 97 | */ 98 | @Deprecated 99 | @Override 100 | default int update(final T entity, final Collection propNamesToUpdate, final Condition cond) 101 | throws UncheckedSQLException, UnsupportedOperationException { 102 | throw new UnsupportedOperationException(); 103 | } 104 | 105 | /** 106 | * Inserts the specified entity if it does not exist, otherwise updates the existing entity. 107 | * 108 | * @param entity the entity to be upserted 109 | * @param uniquePropNamesForQuery the list of property names to be used for querying the uniqueness of the entity 110 | * @return the upserted entity 111 | * @throws UncheckedSQLException if a database access error occurs 112 | * @throws UnsupportedOperationException if the operation is not supported 113 | * @deprecated unsupported Operation 114 | */ 115 | @Deprecated 116 | @Override 117 | default T upsert(final T entity, final List uniquePropNamesForQuery) throws UncheckedSQLException, UnsupportedOperationException { 118 | throw new UnsupportedOperationException(); 119 | } 120 | 121 | /** 122 | * Inserts the specified entity if it does not exist, otherwise updates the existing entity. 123 | * 124 | * @param entity 125 | * @param cond to verify if the record exists or not. 126 | * @return 127 | * @throws UncheckedSQLException 128 | * @throws UnsupportedOperationException 129 | * @deprecated unsupported Operation 130 | */ 131 | @Deprecated 132 | @Override 133 | default T upsert(final T entity, final Condition cond) throws UncheckedSQLException, UnsupportedOperationException { 134 | throw new UnsupportedOperationException(); 135 | } 136 | 137 | /** 138 | * 139 | * @param cond 140 | * @return 141 | * @throws UncheckedSQLException 142 | * @throws UnsupportedOperationException 143 | * @deprecated unsupported Operation 144 | */ 145 | @Deprecated 146 | @Override 147 | default int delete(final Condition cond) throws UncheckedSQLException, UnsupportedOperationException { 148 | throw new UnsupportedOperationException(); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/UncheckedReadOnlyCrudDao.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.util.Collection; 19 | import java.util.List; 20 | 21 | import com.landawn.abacus.annotation.Beta; 22 | import com.landawn.abacus.exception.UncheckedSQLException; 23 | import com.landawn.abacus.util.SQLBuilder; 24 | 25 | /** 26 | * TODO 27 | * 28 | * @param 29 | * @param 30 | * @param 31 | * @param 32 | */ 33 | @Beta 34 | public interface UncheckedReadOnlyCrudDao> 35 | extends UncheckedReadOnlyDao, UncheckedNoUpdateCrudDao, ReadOnlyCrudDao { 36 | 37 | /** 38 | * 39 | * @param entityToInsert 40 | * @return 41 | * @throws UncheckedSQLException 42 | * @throws UnsupportedOperationException 43 | * @deprecated unsupported Operation 44 | */ 45 | @Deprecated 46 | @Override 47 | default ID insert(final T entityToInsert) throws UncheckedSQLException, UnsupportedOperationException { 48 | throw new UnsupportedOperationException(); 49 | } 50 | 51 | /** 52 | * 53 | * @param entityToInsert 54 | * @param propNamesToInsert 55 | * @return 56 | * @throws UncheckedSQLException 57 | * @throws UnsupportedOperationException 58 | * @deprecated unsupported Operation 59 | */ 60 | @Deprecated 61 | @Override 62 | default ID insert(final T entityToInsert, final Collection propNamesToInsert) throws UncheckedSQLException, UnsupportedOperationException { 63 | throw new UnsupportedOperationException(); 64 | } 65 | 66 | /** 67 | * 68 | * @param namedInsertSQL 69 | * @param entityToSave 70 | * @return 71 | * @throws UncheckedSQLException 72 | * @throws UnsupportedOperationException 73 | * @deprecated unsupported Operation 74 | */ 75 | @Deprecated 76 | @Override 77 | default ID insert(final String namedInsertSQL, final T entityToSave) throws UncheckedSQLException, UnsupportedOperationException { 78 | throw new UnsupportedOperationException(); 79 | } 80 | 81 | /** 82 | * 83 | * @param entities 84 | * @return 85 | * @throws UncheckedSQLException 86 | * @throws UnsupportedOperationException 87 | * @deprecated unsupported Operation 88 | */ 89 | @Deprecated 90 | @Override 91 | default List batchInsert(final Collection entities) throws UncheckedSQLException, UnsupportedOperationException { 92 | throw new UnsupportedOperationException(); 93 | } 94 | 95 | /** 96 | * 97 | * @param entities 98 | * @param batchSize 99 | * @return 100 | * @throws UncheckedSQLException 101 | * @throws UnsupportedOperationException 102 | * @deprecated unsupported Operation 103 | */ 104 | @Deprecated 105 | @Override 106 | default List batchInsert(final Collection entities, final int batchSize) throws UncheckedSQLException, UnsupportedOperationException { 107 | throw new UnsupportedOperationException(); 108 | } 109 | 110 | /** 111 | * 112 | * @param entities 113 | * @param propNamesToInsert 114 | * @return 115 | * @throws UncheckedSQLException 116 | * @throws UnsupportedOperationException 117 | * @deprecated unsupported Operation 118 | */ 119 | @Deprecated 120 | @Override 121 | default List batchInsert(final Collection entities, final Collection propNamesToInsert) 122 | throws UncheckedSQLException, UnsupportedOperationException { 123 | throw new UnsupportedOperationException(); 124 | } 125 | 126 | /** 127 | * 128 | * @param entities 129 | * @param propNamesToInsert 130 | * @param batchSize 131 | * @return 132 | * @throws UncheckedSQLException 133 | * @throws UnsupportedOperationException 134 | * @deprecated unsupported Operation 135 | */ 136 | @Deprecated 137 | @Override 138 | default List batchInsert(final Collection entities, final Collection propNamesToInsert, final int batchSize) 139 | throws UncheckedSQLException, UnsupportedOperationException { 140 | throw new UnsupportedOperationException(); 141 | } 142 | 143 | /** 144 | * 145 | * @param namedInsertSQL 146 | * @param entities 147 | * @return 148 | * @throws UncheckedSQLException 149 | * @throws UnsupportedOperationException 150 | * @deprecated unsupported Operation 151 | */ 152 | @Deprecated 153 | @Override 154 | default List batchInsert(final String namedInsertSQL, final Collection entities) 155 | throws UncheckedSQLException, UnsupportedOperationException { 156 | throw new UnsupportedOperationException(); 157 | } 158 | 159 | /** 160 | * 161 | * @param namedInsertSQL 162 | * @param entities 163 | * @param batchSize 164 | * @return 165 | * @throws UncheckedSQLException 166 | * @throws UnsupportedOperationException 167 | * @deprecated unsupported Operation 168 | */ 169 | @Deprecated 170 | @Override 171 | default List batchInsert(final String namedInsertSQL, final Collection entities, final int batchSize) 172 | throws UncheckedSQLException, UnsupportedOperationException { 173 | throw new UnsupportedOperationException(); 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/UncheckedReadOnlyCrudDaoL.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 com.landawn.abacus.annotation.Beta; 19 | import com.landawn.abacus.util.SQLBuilder; 20 | 21 | @Beta 22 | public interface UncheckedReadOnlyCrudDaoL> 23 | extends UncheckedReadOnlyCrudDao, UncheckedNoUpdateCrudDaoL { 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/UncheckedReadOnlyCrudJoinEntityHelper.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 com.landawn.abacus.util.SQLBuilder; 19 | 20 | public interface UncheckedReadOnlyCrudJoinEntityHelper> 21 | extends UncheckedReadOnlyJoinEntityHelper, UncheckedCrudJoinEntityHelper { 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/UncheckedReadOnlyCrudJoinEntityHelperL.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 com.landawn.abacus.util.SQLBuilder; 19 | 20 | public interface UncheckedReadOnlyCrudJoinEntityHelperL> 21 | extends UncheckedReadOnlyJoinEntityHelper, UncheckedCrudJoinEntityHelperL { 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/landawn/abacus/jdbc/dao/UncheckedReadOnlyDao.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.util.Collection; 19 | 20 | import com.landawn.abacus.annotation.Beta; 21 | import com.landawn.abacus.exception.UncheckedSQLException; 22 | import com.landawn.abacus.util.SQLBuilder; 23 | 24 | /** 25 | * TODO 26 | * 27 | * @param 28 | * @param {@code SQLBuilder} used to generate sql scripts. Only can be {@code SQLBuilder.PSC/PAC/PLC} 29 | * @param 30 | */ 31 | @Beta 32 | public interface UncheckedReadOnlyDao> 33 | extends UncheckedNoUpdateDao, ReadOnlyDao { 34 | 35 | /** 36 | * 37 | * 38 | * @param entityToSave 39 | * @throws UncheckedSQLException 40 | * @throws UnsupportedOperationException 41 | * @deprecated unsupported Operation 42 | */ 43 | @Deprecated 44 | @Override 45 | default void save(final T entityToSave) throws UncheckedSQLException, UnsupportedOperationException { 46 | throw new UnsupportedOperationException(); 47 | } 48 | 49 | /** 50 | * 51 | * 52 | * @param entityToSave 53 | * @param propNamesToSave 54 | * @throws UncheckedSQLException 55 | * @throws UnsupportedOperationException 56 | * @deprecated unsupported Operation 57 | */ 58 | @Deprecated 59 | @Override 60 | default void save(final T entityToSave, final Collection propNamesToSave) throws UncheckedSQLException, UnsupportedOperationException { 61 | throw new UnsupportedOperationException(); 62 | } 63 | 64 | /** 65 | * 66 | * 67 | * @param namedInsertSQL 68 | * @param entityToSave 69 | * @throws UncheckedSQLException 70 | * @throws UnsupportedOperationException 71 | * @deprecated unsupported Operation 72 | */ 73 | @Deprecated 74 | @Override 75 | default void save(final String namedInsertSQL, final T entityToSave) throws UncheckedSQLException, UnsupportedOperationException { 76 | throw new UnsupportedOperationException(); 77 | } 78 | 79 | /** 80 | * Always throws {@code UnsupportedOperationException}. 81 | * 82 | * @param entitiesToSave 83 | * @throws UncheckedSQLException 84 | * @throws UnsupportedOperationException 85 | * @deprecated unsupported Operation 86 | */ 87 | @Deprecated 88 | @Override 89 | default void batchSave(final Collection entitiesToSave) throws UncheckedSQLException, UnsupportedOperationException { 90 | throw new UnsupportedOperationException(); 91 | } 92 | 93 | /** 94 | * Always throws {@code UnsupportedOperationException}. 95 | * 96 | * @param entitiesToSave 97 | * @param batchSize 98 | * @throws UncheckedSQLException 99 | * @throws UnsupportedOperationException 100 | * @deprecated unsupported Operation 101 | */ 102 | @Deprecated 103 | @Override 104 | default void batchSave(final Collection entitiesToSave, final int batchSize) throws UncheckedSQLException, UnsupportedOperationException { 105 | throw new UnsupportedOperationException(); 106 | } 107 | 108 | /** 109 | * Always throws {@code UnsupportedOperationException}. 110 | * 111 | * @param entitiesToSave 112 | * @param propNamesToSave 113 | * @throws UncheckedSQLException 114 | * @throws UnsupportedOperationException 115 | * @deprecated unsupported Operation 116 | */ 117 | @Deprecated 118 | @Override 119 | default void batchSave(final Collection entitiesToSave, final Collection propNamesToSave) 120 | throws UncheckedSQLException, UnsupportedOperationException { 121 | throw new UnsupportedOperationException(); 122 | } 123 | 124 | /** 125 | * Always throws {@code UnsupportedOperationException}. 126 | * 127 | * @param entitiesToSave 128 | * @param propNamesToSave 129 | * @param batchSize 130 | * @throws UncheckedSQLException 131 | * @throws UnsupportedOperationException 132 | * @deprecated unsupported Operation 133 | */ 134 | @Deprecated 135 | @Override 136 | default void batchSave(final Collection entitiesToSave, final Collection propNamesToSave, final int batchSize) 137 | throws UncheckedSQLException, UnsupportedOperationException { 138 | throw new UnsupportedOperationException(); 139 | } 140 | 141 | /** 142 | * Always throws {@code UnsupportedOperationException}. 143 | * 144 | * @param namedInsertSQL 145 | * @param entitiesToSave 146 | * @throws UncheckedSQLException 147 | * @throws UnsupportedOperationException 148 | * @deprecated unsupported Operation 149 | */ 150 | @Deprecated 151 | @Override 152 | default void batchSave(final String namedInsertSQL, final Collection entitiesToSave) 153 | throws UncheckedSQLException, UnsupportedOperationException { 154 | throw new UnsupportedOperationException(); 155 | } 156 | 157 | /** 158 | * Always throws {@code UnsupportedOperationException}. 159 | * 160 | * @param namedInsertSQL 161 | * @param entitiesToSave 162 | * @param batchSize 163 | * @throws UncheckedSQLException 164 | * @throws UnsupportedOperationException 165 | * @deprecated unsupported Operation 166 | */ 167 | @Deprecated 168 | @Override 169 | default void batchSave(final String namedInsertSQL, final Collection entitiesToSave, final int batchSize) 170 | throws UncheckedSQLException, UnsupportedOperationException { 171 | throw new UnsupportedOperationException(); 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /src/test/java/com/landawn/abacus/Maven.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 HaiYang Li 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * https://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package com.landawn.abacus; 15 | 16 | import java.io.File; 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import com.landawn.abacus.util.IOUtil; 21 | import com.landawn.abacus.util.N; 22 | import com.landawn.abacus.util.Strings; 23 | import com.landawn.abacus.util.stream.Stream.StreamEx; 24 | 25 | public class Maven { 26 | 27 | public static void main(final String[] args) throws Exception { 28 | N.println(new File(".").getAbsolutePath()); 29 | 30 | final String sourceVersion = "0.0.1-SNAPSHOT"; 31 | final String targetVersion = StreamEx.ofLines(new File("./pom.xml")) 32 | .filter(line -> line.indexOf("") > 0 && line.indexOf("") > 0) 33 | .first() 34 | .map(line -> Strings.substringsBetween(line, "", "").get(0)) 35 | .get(); 36 | 37 | final String commonMavenPath = "./maven/"; 38 | final String sourcePath = commonMavenPath + sourceVersion; 39 | final String targetPath = commonMavenPath + targetVersion; 40 | final File sourceDir = new File(sourcePath); 41 | final File targetDir = new File(targetPath); 42 | 43 | IOUtil.deleteAllIfExists(targetDir); 44 | 45 | targetDir.mkdir(); 46 | 47 | IOUtil.copyToDirectory(sourceDir, targetDir); 48 | 49 | StreamEx.listFiles(new File("./target/")) 50 | .filter(f -> f.getName().startsWith("abacus-jdbc") && f.getName().endsWith(".jar")) 51 | .peek(f -> N.println(f.getName())) 52 | .forEach(f -> IOUtil.copyToDirectory(f, targetDir)); 53 | 54 | StreamEx.listFiles(targetDir) // 55 | .forEach(file -> IOUtil.renameTo(file, file.getName().replace(sourceVersion, targetVersion))); 56 | 57 | StreamEx.listFiles(targetDir) 58 | .filter(file -> file.getName().endsWith(".pom") || file.getName().endsWith(".xml") || file.getName().endsWith(".txt")) 59 | .forEach(file -> { 60 | final List lines = IOUtil.readAllLines(file); 61 | final List newLines = new ArrayList<>(lines.size()); 62 | for (final String line : lines) { 63 | newLines.add(line.replaceAll(sourceVersion, targetVersion)); 64 | } 65 | IOUtil.writeLines(newLines, file); 66 | }); 67 | 68 | System.exit(0); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/test/java/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | --------------------------------------------------------------------------------