From 5132760ff62f6df46710e35660765ff01c36ec97 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 08:14:15 +0000 Subject: [PATCH 1/2] Initial plan From bd6e7baf3d0c1ada04d1c26ab3db5972e84b69e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 08:18:49 +0000 Subject: [PATCH 2/2] Add JDBC versus jOOQ pattern (enterprise/jdbc-vs-jooq) Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com> --- content/enterprise/jdbc-vs-jooq.json | 54 +++++++++++++++++++ .../spring-xml-config-vs-annotations.json | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 content/enterprise/jdbc-vs-jooq.json diff --git a/content/enterprise/jdbc-vs-jooq.json b/content/enterprise/jdbc-vs-jooq.json new file mode 100644 index 0000000..e8e7331 --- /dev/null +++ b/content/enterprise/jdbc-vs-jooq.json @@ -0,0 +1,54 @@ +{ + "id": 112, + "slug": "jdbc-vs-jooq", + "title": "JDBC versus jOOQ", + "category": "enterprise", + "difficulty": "intermediate", + "jdkVersion": "11", + "oldLabel": "Raw JDBC", + "modernLabel": "jOOQ", + "oldApproach": "Raw JDBC", + "modernApproach": "jOOQ SQL DSL", + "oldCode": "String sql = \"SELECT id, name, email FROM users \"\n + \"WHERE department = ? AND salary > ?\";\ntry (Connection con = ds.getConnection();\n PreparedStatement ps =\n con.prepareStatement(sql)) {\n ps.setString(1, department);\n ps.setBigDecimal(2, minSalary);\n ResultSet rs = ps.executeQuery();\n List result = new ArrayList<>();\n while (rs.next()) {\n result.add(new User(\n rs.getLong(\"id\"),\n rs.getString(\"name\"),\n rs.getString(\"email\")));\n }\n return result;\n}", + "modernCode": "DSLContext dsl = DSL.using(ds, SQLDialect.POSTGRES);\n\nreturn dsl\n .select(USERS.ID, USERS.NAME, USERS.EMAIL)\n .from(USERS)\n .where(USERS.DEPARTMENT.eq(department)\n .and(USERS.SALARY.gt(minSalary)))\n .fetchInto(User.class);", + "summary": "Replace raw JDBC string-based SQL with jOOQ's type-safe, fluent SQL DSL.", + "explanation": "jOOQ (Java Object Oriented Querying) generates Java code from your database schema, turning table and column names into type-safe Java constants. The fluent DSL mirrors SQL syntax so queries are readable and composable. All parameters are bound automatically, eliminating SQL injection risk. Unlike JPA/JPQL, jOOQ embraces SQL fully — window functions, CTEs, RETURNING clauses, and vendor-specific extensions are all first-class.", + "whyModernWins": [ + { + "icon": "🔒", + "title": "Type-safe columns", + "desc": "Column names are generated Java constants — typos and type mismatches become compiler errors instead of runtime failures." + }, + { + "icon": "📖", + "title": "SQL fluency", + "desc": "The jOOQ DSL mirrors SQL syntax closely, so complex JOINs, subqueries, and CTEs stay readable." + }, + { + "icon": "🛡️", + "title": "Injection-free by design", + "desc": "Parameters are always bound safely — no string concatenation means no SQL injection risk." + } + ], + "support": { + "state": "available", + "description": "jOOQ open-source edition supports all major open-source databases; older commercial databases require a paid license" + }, + "prev": "enterprise/spring-xml-config-vs-annotations", + "next": null, + "related": [ + "enterprise/jdbc-vs-jpa", + "enterprise/jdbc-resultset-vs-jpa-criteria", + "enterprise/manual-transaction-vs-declarative" + ], + "docs": [ + { + "title": "jOOQ — Getting Started", + "href": "https://www.jooq.org/doc/latest/manual/getting-started/" + }, + { + "title": "jOOQ — DSL API Reference", + "href": "https://www.jooq.org/javadoc/latest/" + } + ] +} diff --git a/content/enterprise/spring-xml-config-vs-annotations.json b/content/enterprise/spring-xml-config-vs-annotations.json index 8fd021b..f102418 100644 --- a/content/enterprise/spring-xml-config-vs-annotations.json +++ b/content/enterprise/spring-xml-config-vs-annotations.json @@ -35,7 +35,7 @@ "description": "Widely available since Spring Boot 1.0 (April 2014); Spring Boot 3 requires Java 17+" }, "prev": "enterprise/jdbc-resultset-vs-jpa-criteria", - "next": null, + "next": "enterprise/jdbc-vs-jooq", "related": [ "enterprise/ejb-vs-cdi", "enterprise/jndi-lookup-vs-cdi-injection",