{"id":13471077,"url":"https://github.com/jOOQ/jOOQ","last_synced_at":"2025-03-26T13:30:45.071Z","repository":{"id":37405481,"uuid":"1625986","full_name":"jOOQ/jOOQ","owner":"jOOQ","description":"jOOQ is the best way to write SQL in Java","archived":false,"fork":false,"pushed_at":"2025-03-25T10:23:35.000Z","size":277329,"stargazers_count":6342,"open_issues_count":2060,"forks_count":1214,"subscribers_count":155,"default_branch":"main","last_synced_at":"2025-03-25T12:17:23.875Z","etag":null,"topics":["code-generator","database","db2","hibernate","java","jdbc","jdbc-utilities","jooq","jpa","mysql","oracle","orm","postgresql","sql","sql-builder","sql-formatter","sql-query","sql-query-builder","sql-query-formatter","sqlserver"],"latest_commit_sha":null,"homepage":"https://www.jooq.org","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jOOQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-04-17T10:43:33.000Z","updated_at":"2025-03-25T12:02:01.000Z","dependencies_parsed_at":"2024-04-02T10:26:52.728Z","dependency_job_id":"24a88433-33b0-454b-a765-d06490e6deb6","html_url":"https://github.com/jOOQ/jOOQ","commit_stats":{"total_commits":13335,"total_committers":110,"mean_commits":"121.22727272727273","dds":0.05174353205849269,"last_synced_commit":"662243d51bf1726f727cf39c6cc9ffb3bb043f03"},"previous_names":[],"tags_count":272,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOQ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOQ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOQ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOQ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jOOQ","download_url":"https://codeload.github.com/jOOQ/jOOQ/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245662726,"owners_count":20652071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["code-generator","database","db2","hibernate","java","jdbc","jdbc-utilities","jooq","jpa","mysql","oracle","orm","postgresql","sql","sql-builder","sql-formatter","sql-query","sql-query-builder","sql-query-formatter","sqlserver"],"created_at":"2024-07-31T16:00:39.451Z","updated_at":"2025-03-26T13:30:45.039Z","avatar_url":"https://github.com/jOOQ.png","language":"Java","readme":"jOOQ\n====\n\njOOQ is an internal DSL and source code generator, modelling the SQL language as a type safe Java API to help you write better SQL. \n\nIts main features include:\n\n- [The source code generator](https://blog.jooq.org/why-you-should-use-jooq-with-code-generation/)\n- The [DSL API for type safe query construction](https://www.jooq.org/doc/latest/manual/sql-building/dsl-api/) and [dynamic SQL](https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql/)\n\nSecondary features include:\n\n- [DAOs](https://www.jooq.org/doc/latest/manual/sql-execution/daos/)\n- [Data export](https://www.jooq.org/doc/latest/manual/sql-execution/exporting/) and [import](https://www.jooq.org/doc/latest/manual/sql-execution/importing/)\n- [Data type conversion](https://www.jooq.org/doc/latest/manual/sql-execution/fetching/data-type-conversion/)\n- [DDL statement support](https://www.jooq.org/doc/latest/manual/sql-building/ddl-statements/)\n- [DML statement support](https://www.jooq.org/doc/latest/manual/sql-building/sql-statements/)\n- [Diagnostics](https://www.jooq.org/doc/latest/manual/sql-execution/diagnostics/)\n- [Dialect agnosticity for 30+ RDBMS](https://www.jooq.org/download/#databases)\n- [Embedded types](https://www.jooq.org/doc/latest/manual/code-generation/codegen-embeddable-types/)\n- [Formatting and pretty printing](https://www.jooq.org/doc/latest/manual/sql-building/queryparts/pretty-printing/)\n- [Implicit joins](https://www.jooq.org/doc/latest/manual/sql-building/sql-statements/select-statement/implicit-join/)\n- [Kotlin support](https://www.jooq.org/doc/latest/manual/sql-building/kotlin-sql-building/)\n- [Mapping](https://www.jooq.org/doc/latest/manual/sql-execution/fetching/recordmapper/)\n- [Meta data API](https://www.jooq.org/doc/latest/manual/sql-execution/meta-data/)\n- [Mocking API for JDBC](https://www.jooq.org/doc/latest/manual/sql-execution/mocking-connection/)\n- [Model API for use in traversal and replacement](https://www.jooq.org/doc/latest/manual/sql-building/model-api/)\n- [`MULTISET` and `ROW` nested collections and records](https://blog.jooq.org/jooq-3-15s-new-multiset-operator-will-change-how-you-think-about-sql/)\n- [Multitenancy](https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/settings-render-mapping/)\n- [Parser (and translator)](https://www.jooq.org/doc/latest/manual/sql-building/sql-parser/)\n- [Pattern based transformation](https://www.jooq.org/doc/latest/manual/sql-building/queryparts/sql-transformation/transform-patterns/)\n- [Plain SQL templating](https://www.jooq.org/doc/latest/manual/sql-building/plain-sql-templating/)\n- [Policies](https://www.jooq.org/doc/latest/manual/sql-building/queryparts/policies/)\n- [Procedural logic API](https://blog.jooq.org/vendor-agnostic-dynamic-procedural-logic-with-jooq/)\n- [Reactive support via R2DBC](https://www.jooq.org/doc/latest/manual/sql-execution/fetching/reactive-fetching/)\n- [Readonly columns](https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-readonly-columns/)\n- [Scala support](https://www.jooq.org/doc/latest/manual/sql-building/scala-sql-building/)\n- [Schema diff](https://www.jooq.org/doc/latest/manual/sql-building/schema-diff/)\n- [SQL transformation](https://www.jooq.org/doc/latest/manual/sql-building/queryparts/sql-transformation/)\n- [SQL translation](https://www.jooq.org/translate/)\n- [Stored procedure support](https://blog.jooq.org/the-best-way-to-call-stored-procedures-from-java-with-jooq/)\n- [Transaction API](https://www.jooq.org/doc/latest/manual/sql-execution/transaction-management/)\n- [UpdatableRecords for simplified CRUD, with opt-in optimistic locking](https://www.jooq.org/doc/latest/manual/sql-execution/crud-with-updatablerecords/simple-crud/)\n- And much more\n\nExamples\n========\n\nTypesafe, embedded SQL\n----------------------\n\njOOQ's main feature is typesafe, embedded SQL, allowing for IDE auto completion of SQL syntax...\n\n![image](https://github.com/jOOQ/jOOQ/assets/734593/a62305d7-c8a7-4a32-aa32-30708f70337d)\n\n... as well as of schema meta data:\n\n![image](https://github.com/jOOQ/jOOQ/assets/734593/a8e23067-254c-4a03-89b2-82985325ee69)\n\nThis allows for preventing errors of various types, including typos of identifiers:\n\n![image](https://github.com/jOOQ/jOOQ/assets/734593/d2659a0c-7d45-4851-9455-81ac4bc18485)\n\nOr data type mismatches:\n\n![image](https://github.com/jOOQ/jOOQ/assets/734593/8d230f16-ce82-4de8-88b2-64997451ebfe)\n\n[The examples are from the code generation blog post](https://blog.jooq.org/why-you-should-use-jooq-with-code-generation/).\n\nA more powerful example using nested collections\n------------------------------------------------\n\nFor many more examples, [please have a look at the demo](https://github.com/jOOQ/demo). A key example showing jOOQ's various strengths is from the [`MULTISET` operator announcement blog post](https://blog.jooq.org/jooq-3-15s-new-multiset-operator-will-change-how-you-think-about-sql/):\n\nGiven these target DTOs:\n\n```java\nrecord Actor(String firstName, String lastName) {}\nrecord Film(\n  String title,\n  List\u003cActor\u003e actors,\n  List\u003cString\u003e categories\n) {}\n```\n\nYou can now write the following query to fetch films, their nested actors and their nested categorise in a single, type safe query:\n\n```java\nList\u003cFilm\u003e result =\ndsl.select(\n      FILM.TITLE,\n      multiset(\n        select(\n          FILM.actor().FIRST_NAME, \n          FILM.actor().LAST_NAME)\n        .from(FILM.actor())\n      ).as(\"actors\").convertFrom(r -\u003e r.map(mapping(Actor::new))),\n      multiset(\n        select(FILM.category().NAME)\n        .from(FILM.category())\n      ).as(\"categories\").convertFrom(r -\u003e r.map(Record1::value1))\n   )\n   .from(FILM)\n   .orderBy(FILM.TITLE)\n   .fetch(mapping(Film::new));\n```\n\nThe query is completely type safe. Change a column type, name, or the target DTO, and it will stop compiling! Trust only your own eyes:\n\n![multiset](https://github.com/jOOQ/jOOQ/assets/734593/948f8e62-2a93-4152-86d6-42a6eceb7133)\n\nAnd here you see the nested result in action from the logs:\n\n![execute](https://github.com/jOOQ/jOOQ/assets/734593/ba2f2a9f-218c-4ec9-8fb2-c2b8b7df2f4d)\n\nHow does it work? Look at this annotated example:\n\n\n```java\nList\u003cFilm\u003e result =\ndsl.select(\n      FILM.TITLE,\n\n      // MULTISET is a standard SQL operator that allows for nesting collections\n      // directly in SQL. It is either\n      // - supported natively\n      // - emulated using SQL/JSON or SQL/XML\n      multiset(\n\n        // Implicit path based joins allow for simpler navigation of foreign\n        // key relationships.\n        select(\n          FILM.actor().FIRST_NAME, \n          FILM.actor().LAST_NAME)\n\n        // Implicit correlation to outer queries allows for avoiding repetitive\n        // writing of predicates.\n        .from(FILM.actor())\n\n      // Ad-hoc conversion allows for mapping structural Record2\u003cString, String\u003e\n      // types to your custom DTO using constructor references\n      ).as(\"actors\").convertFrom(r -\u003e r.map(mapping(Actor::new))),\n      multiset(\n        select(FILM.category().NAME)\n        .from(FILM.category())\n      ).as(\"categories\").convertFrom(r -\u003e r.map(Record1::value1))\n   )\n   .from(FILM)\n   .orderBy(FILM.TITLE)\n   .fetch(mapping(Film::new));\n```\n\nThe generated SQL query might look like this, in PostgreSQL:\n\n```sql\nselect\n  film.title,\n  (\n    select coalesce(\n      jsonb_agg(jsonb_build_object(\n        'first_name', t.first_name,\n        'last_name', t.last_name\n      )),\n      jsonb_build_array()\n    )\n    from (\n      select\n        alias_78509018.first_name, \n        alias_78509018.last_name\n      from (\n        film_actor\n          join actor as alias_78509018\n            on film_actor.actor_id = alias_78509018.actor_id\n        )\n      where film_actor.film_id = film.film_id\n    ) as t\n  ) as actors,\n  (\n    select coalesce(\n      jsonb_agg(jsonb_build_object('name', t.name)),\n      jsonb_build_array()\n    )\n    from (\n      select alias_130639425.name\n      from (\n        film_category\n          join category as alias_130639425\n            on film_category.category_id = alias_130639425.category_id\n        )\n      where film_category.film_id = film.film_id\n    ) as t\n  ) as categories\nfrom film\norder by film.title\n```\n\nThis particular example is explained more in detail in the [`MULTISET` operator announcement blog post](https://blog.jooq.org/jooq-3-15s-new-multiset-operator-will-change-how-you-think-about-sql/). For many more examples, [please have a look at the demo](https://github.com/jOOQ/demo).\n","funding_links":[],"categories":["Java","数据库开发","II. Databases, search engines, big data and machine learning","SQL"],"sub_categories":["5. ORM","Parsers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjOOQ%2FjOOQ","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FjOOQ%2FjOOQ","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjOOQ%2FjOOQ/lists"}