{"id":21725142,"url":"https://github.com/landawn/abacus-jdbc","last_synced_at":"2026-03-05T05:01:19.437Z","repository":{"id":37044538,"uuid":"212016492","full_name":"landawn/abacus-jdbc","owner":"landawn","description":"Coding with SQL/DB is just like coding with Collections","archived":false,"fork":false,"pushed_at":"2026-02-28T08:51:26.000Z","size":83536,"stargazers_count":18,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-28T13:49:19.733Z","etag":null,"topics":["dao","java","jdbc","jpa","orm","sql","sqlbuilder"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/landawn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-10-01T05:05:08.000Z","updated_at":"2026-02-28T08:51:29.000Z","dependencies_parsed_at":"2026-02-28T10:05:07.025Z","dependency_job_id":null,"html_url":"https://github.com/landawn/abacus-jdbc","commit_stats":null,"previous_names":[],"tags_count":184,"template":false,"template_full_name":null,"purl":"pkg:github/landawn/abacus-jdbc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landawn%2Fabacus-jdbc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landawn%2Fabacus-jdbc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landawn%2Fabacus-jdbc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landawn%2Fabacus-jdbc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/landawn","download_url":"https://codeload.github.com/landawn/abacus-jdbc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landawn%2Fabacus-jdbc/sbom","scorecard":{"id":578307,"data":{"date":"2025-08-11","repo":{"name":"github.com/landawn/abacus-jdbc","commit":"48ff009fc0d4d0382d5ca64200825d8441c15873"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":10,"reason":"18 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T18:27:00.093Z","repository_id":37044538,"created_at":"2025-08-20T18:27:00.093Z","updated_at":"2025-08-20T18:27:00.093Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30111715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dao","java","jdbc","jpa","orm","sql","sqlbuilder"],"created_at":"2024-11-26T03:15:38.821Z","updated_at":"2026-03-05T05:01:19.423Z","avatar_url":"https://github.com/landawn.png","language":"Java","readme":"# abacus-jdbc\r\n\r\n[![Maven Central](https://img.shields.io/maven-central/v/com.landawn/abacus-jdbc.svg)](https://maven-badges.herokuapp.com/maven-central/com.landawn/abacus-jdbc/)\r\n[![Javadocs](https://img.shields.io/badge/javadoc-4.6.2-brightgreen.svg)](https://www.javadoc.io/doc/com.landawn/abacus-jdbc/4.6.2/index.html)\r\n\r\nExperience the simplicity of working with SQL/DB as naturally as working with Collections.\r\n\r\n## Features:\r\n\r\nThis library focuses on three core areas:\r\n\r\n*  Write or generate `SQL scripts` (optional):: [SQLBuilder](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/SQLBuilder_view.html), \r\n[DynamicSQLBuilder](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/DynamicSQLBuilder_view.html).\r\n\r\n```java\r\n// Manually write the sql in plain string.\r\nString query = \"SELECT id, first_name, last_name, email FROM user WHERE first_Name = ?\";\r\n\r\n// Or by SQLBuilder\r\nString query = PSC.select(\"id\", \"firstName, \"lastName\", \"email\").from(User.class).where(Filters.eq(\"firstName\")).sql();\r\n// Or if select all columns from user:\r\nString query = PSC.selectFrom(User.class).where(Filters.eq(\"firstName\")).sql();\r\n\r\n// Sql scripts can also be placed in sql mapper xml file and then associated with a DAO object.\r\nUserDao userDao =  JdbcUtil.createDao(UserDao.class, dataSource, sqlMapper);\r\n```\r\n`userSqlMapper.xml`\r\n```xml\r\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\r\n\u003csqlMapper\u003e\r\n\t\u003csql id=\"selectUserByFirstName\"\u003eSELECT id, first_name, last_name, email FROM user WHERE first_Name = ?\u003c/sql\u003e\r\n\u003c/sqlMapper\u003e\r\n```\r\n\r\n\u003cbr /\u003e\r\n\r\n*  Prepare `statements/queries`: [PreparedQuery](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/PreparedQuery_view.html), \r\n[NamedQuery](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/NamedQuery_view.html), \r\n[CallableQuery](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/CallableQuery_view.html) with a `sql` or `Dao` mapped with `sqls`.\r\n\r\n```java\r\n// sql can be used to create PreparedQuery/NamedQuery/CallableQuery\r\nPreparedQuery preparedQuery = JdbcUtil.prepareQuery(dataSource, query...); \r\n\t\t\t            //.prepareQuery(connection, query...)\t\t\r\n\t\t\t            //.prepareNamedQuery(dataSource, namedQuery...)\t\t\t\t\t\t\t\t\t   \r\n\t\t\t            //.prepareCallableQuery(dataSource, query...)\t\t\t\t\t\t\t\t\t   \r\n\t\t\t            //....\t\r\n\t\t\t\t      .setString(1, fistName) // Firstly set query parameters, if needed.\r\n\t\t\t\t    //.setLong(paramName, paramValue) // set named parameters for NamedQuery/CallableQuery.\r\n\t\t\t\t    //.setParameters(entity) // set named parameters by entity with getter/setter methods\r\n\t\t\t\t    //.setParameters(Map\u003cString, ?\u003e) // set named parameters by Map\r\n\t\t\t\t    //.setParameters(param1, param2...) // set several parameters in one line.\r\n\t\t\t\t    //.setParameters(Collection\u003c?\u003e parameters) // set parameters with a Collection.\r\n\t\t\t\t    //.setParameters(ParametersSetter parametersSetter) // set parameters by functional interface. \r\n\t\t\t\t    //....  \t\t\t\t\t\t\t\t\t   \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \r\n\r\n// Sql can also be associated to a self-defined DAO method. (There are tens of most used predefined methods in DAO interfaces which be used without write single line of code).\r\npublic interface UserDao extends CrudDao\u003cUser, Long, SQLBuilder.PSC, UserDao\u003e, JoinEntityHelper\u003cUser, SQLBuilder.PSC, UserDao\u003e {\r\n    // This is just a sample. Normally there are pre-defined methods available for this query: userDao.list(Condition cond).\r\n    // Methods defined in Dao interface don't require implementation. Of course, Customized implemnetation is also supported by default method.\r\n    @Query(\"SELECT id, first_name, last_name, email FROM user WHERE first_Name = ?\")\r\n    List\u003cUser\u003e selectUserByFirstName(String firstName) throws SQLException;\r\n    \r\n    // Or id of the sql script defined in xml mapper file.\r\n    @Query(id = \"selectUserByFirstName\")\r\n    List\u003cUser\u003e selectUserByFirstName(String firstName) throws SQLException;\r\n\r\n    // Or id of the sql script defined in below nested static class.\r\n    // Instead of writing sql scripts manually, you can also use SQLBuilder/DynamicSQLBuilder to write sql scripts.\r\n    @Query(id = \"selectUserByFirstName\")\r\n    List\u003cUser\u003e selectUserByFirstName(String firstName) throws SQLException;\r\n    \r\n    // Multiple updates within transaction.\r\n    @Transactional\r\n    @Query({ \"update user set first_name = ? where id = ?\", \r\n            \"update user set last_name = ? where id = :id\" })\r\n    default void updateFirstNameLastNameByIds(long idForUpdateFirstName, long idForUpdateLastName, String... sqls) throws SQLException { // Last parameter must be String[]. It will be automatically filled with sqls in @Sql.\r\n        prepareQuery(sqls[0]).setLong(1, idForUpdateFirstName).update();\r\n        prepareNamedQuery(sqls[1]).setLong(1, idForUpdateLastName).update();\r\n    }\r\n\r\n    // Refer classes in package com.landawn.abacus.jdbc.annotation for more supported annations\r\n    @Query(\"SELECT * FROM {tableName} where id = :id ORDER BY {{orderBy}}\")\r\n    User selectByIdWithDefine(@Define(\"tableName\") String tableName, @Define(\"{{orderBy}}\") String orderBy, @Bind(\"id\") long id);\r\n\r\n    static final class SqlTable {\r\n        @SqlScript\r\n        static final String selectUserByFirstName = PSC.select(\"id\", \"firstName, \"lastName\", \"email\").from(User.class).where(Filters.eq(\"first\")).sql();\r\n    }\r\n}\r\n\r\nUserDao userDao =  JdbcUtil.createDao(UserDao.class, dataSource, ...);\r\n```\r\n\u003cbr /\u003e\r\n\r\n* Execute and retrieve results (when needed):\r\n[Dao](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/Dao_view.html)/[CrudDao](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/CrudDao_view.html)/[JoinEntityHelper](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/JoinEntityHelper_view.html), \r\n[Jdbc](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/Jdbc_view.html),\r\n[Dataset](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/Dataset_view.html), \r\n[Filters](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/Filters_view.html), \r\n[JdbcUtil](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/JdbcUtil_view.html),\r\n[JdbcUtils](https://htmlpreview.github.io/?https://github.com/landawn/abacus-jdbc/blob/master/docs/JdbcUtils_view.html).\r\n\r\n```java\r\n// Execute the sql by a PreparedQuery/NamedQuery/CallableQuery\r\npreparedQuery.findFirst()\r\n           //.findFirst(User.class)/findFirst(rowMapper)/...\r\n           //.findOnlyOne()/findOnlyOne(User.class)/findOnlyOne(rowMapper)/...\r\n           //.list()/list(User.class)/list(rowMapper)/...\r\n           //.stream()/stream(User.class)/stream(rowMapper)/...\r\n\t   //.query()/qurey(resultExtractor)/queryForInt/queryForString/queryForSingleResult/...\r\n           //.exists()/ifExists(rowConsumer)\r\n\t   //.update/batchUpdate/execute/...\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \r\n\r\n// Sql can also be executed by directly calling DAO methods.\r\nuserDao.selectUserByFirstName(firstName)\r\n     //.updateFirstNameLastNameByIds(100, 101)\r\n     //.findFirst(Condition)\r\n     //.findOnlyOne(Condition)\r\n     //.list(Condition)\r\n     //.stream(Condition)\r\n     //.update(user)/deleteById(userId)/batchInsert(Collection\u003cUser\u003e)/...\r\n\r\n```\r\n\u003cbr /\u003e\r\n\r\n\r\n* Code Generation: [CodeGenerationUtil](https://www.javadoc.io/doc/com.landawn/abacus-common/latest/com/landawn/abacus/util/CodeGenerationUtil.html), [JdbcCodeGenerationUtil](https://www.javadoc.io/doc/com.landawn/abacus-jdbc/latest/com/landawn/abacus/jdbc/JdbcCodeGenerationUtil.html).\r\n\r\n## Why abacus-jdbc?\r\n\r\nThe biggest difference between this library and other data(database) access frameworks is the simplicity/consistency/integrity in the APIs design.\r\nRefer to: [Abacus-JDBC vs Spring Data (JPA \u0026 JDBC), MyBatis, and Hibernate – A Comparative Analysis](https://github.com/landawn/abacus-jdbc/blob/master/docs/Abacus-JDBC%20vs%20Spring%20Data%20(JPA%20%26%20JDBC)%2C%20MyBatis%2C%20and%20Hibernate%20%E2%80%93%20A%20Comparative%20Analysis.pdf)\r\n\r\n## Design and Implementation Considerations:\r\n\r\n* In general, embedding SQL scripts where they are used is easier to review and maintain than saving them in separate files.\r\n\r\n* While high-level abstractions such as JPA or Spring’s `CrudRepository` enhance development productivity, preserving the ability for users to write and execute SQL offers essential flexibility. SQL is a simple, expressive, and powerful language, and should be leveraged instead of being avoided without justification.\r\n\r\n* High-level abstraction APIs should simplify implementation, improve productivity, and avoid increasing complexity or reducing performance.\r\n\r\n## Download/Installation \u0026 [Changes](https://github.com/landawn/abacus-jdbc/blob/master/CHANGES.md):\r\n\r\n* [Maven](https://central.sonatype.com/artifact/com.landawn/abacus-jdbc)\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n\t\u003cgroupId\u003ecom.landawn\u003c/groupId\u003e\r\n\t\u003cartifactId\u003eabacus-jdbc\u003c/artifactId\u003e\r\n\t\u003cversion\u003e4.6.2\u003c/version\u003e \r\n\u003cdependency\u003e\r\n```\r\n\r\n* Gradle:\r\n\r\n```gradle\r\n// JDK 17 or above:\r\ncompile 'com.landawn:abacus-jdbc:4.6.2'\r\n```\r\n\r\n## User Guide:\r\n* [Introduction to JDBC](https://www.javacodegeeks.com/2015/02/jdbc-tutorial.html)\r\n* [More samples/questions(?)](https://github.com/landawn/abacus-jdbc/tree/master/samples/com/landawn/abacus/samples)\r\n\r\n## Also See: [abacus-common](https://github.com/landawn/abacus-common), [abacus-entity-manager](https://github.com/landawn/abacus-entity-manager).\r\n\r\n## Recommended Java programming libraries/frameworks:\r\n[lombok](https://github.com/rzwitserloot/lombok), \r\n[Apache Druid](https://github.com/apache/druid), \r\n[Sharding-JDBC](https://github.com/apache/incubator-shardingsphere)\r\n... [awesome-java](https://github.com/akullpp/awesome-java#database)\r\n\r\n\r\n## Recommended Java programming tools:\r\n[Spotbugs](https://github.com/spotbugs/spotbugs), [JaCoCo](https://www.eclemma.org/jacoco/)...\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flandawn%2Fabacus-jdbc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flandawn%2Fabacus-jdbc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flandawn%2Fabacus-jdbc/lists"}