Typesafe embedded DSLs like jOOQ are extremely powerful for dynamic SQL, because the query you're constructing with the jOOQ DSL is a dynamic query by nature. You're constructing a query expression tree using a convenient API (the "DSL"), even if you think your SQL statement is static. For instance: for (Record rec : ctx.select(ACTOR.FIRST_NAME, ACTOR.LAST_NAME) … Continue reading A Functional Programming Approach to Dynamic SQL with jOOQ
Tag: dsl
A Curious Incidence of a jOOQ API Design Flaw
jOOQ is an internal domain-specific language (DSL), modelling the SQL language (external DSL) in Java (the host language). The main mechanism of the jOOQ API is described in this popular article: The Java Fluent API Designer Crash Course. Anyone can implement an internal DSL in Java (or in most other host languages) according to the … Continue reading A Curious Incidence of a jOOQ API Design Flaw
A SQL query DSL for Scala by ScalikeJDBC
There are a tremendous amount of SQL APIs natively written in Scala. Manuel Bernhardt has summarised a nice collection in his a post. Another collection of Scala SQL APIs can be seen in this Stack Overflow question. One API that we want to focus on in particular is ScalikeJDBC (licensed ASL 2.0), which has recently … Continue reading A SQL query DSL for Scala by ScalikeJDBC
Using jOOQ With Groovy
Some people may be using jOOQ with Groovy for easy scripting. As with the existing jOOQ / Scala integration, some Groovy language features can be leveraged. Take the following example, for instance: package org.jooq.groovy import static org.jooq.impl.DSL.* import static org.jooq.groovy.example.h2.Tables.* import groovy.sql.Sql import org.jooq.* import org.jooq.impl.DSL sql = Sql.newInstance( 'jdbc:h2:~/scala-test', 'sa', '', 'org.h2.Driver') a = … Continue reading Using jOOQ With Groovy
Nice Tutorial for Creating an External DSL with Xtext
When blogging about DSLs, I'm mostly blogging about internal domain-specific languages, because jOOQ is a good example for internal DSLs. But external domain-specific languages are an interesting topic as well. As an external DSL does not depend on any host language (e.g. Java), it can be much richer in syntax and expressivity. On the other … Continue reading Nice Tutorial for Creating an External DSL with Xtext
Internal DSLs on the Fast Lane
I've read this interesting article about internal DSLs in Java, a short summary of Martin Fowler's book on DSLs in general. I've been blogging about external and internal DSLs quite a lot myself, naturally, as jOOQ is the largest and most advanced free and Open Source implementation of an internal DSL in the Java ecosystem. … Continue reading Internal DSLs on the Fast Lane
A Typesafety Comparison of SQL Access APIs
SQL is a very expressive and distinct language. It is one of the few declarative languages which are used by a broad audience in everyday work. As a declarative language, SQL allows to specify what we're expecting as output, not how this output should be produced. As a side-effect of this, ad-hoc record data types … Continue reading A Typesafety Comparison of SQL Access APIs
ElSql, a new external SQL DSL for Java
Stephen Colebourne who is frequently commenting on the lambda-dev and other Java 8 mailing lists, has recently published an idea he has been having for a while: ElSql, a new external SQL DSL for Java. An example SQL statement is given on the blog posts or on GitHub: @NAME(SelectBlogs) @PAGING(:paging_offset,:paging_fetch) SELECT @INCLUDE(CommonFields) FROM blogs WHERE … Continue reading ElSql, a new external SQL DSL for Java
jOOQ’s fluent API in BNF notation
I have recently posted an article about how to generally design a fluent API in Java. By fluent API, I don't mean simple constructs such as new Builder().withSomething(x) .withSomethingElse(y) .withSomething(z) .withAnotherThing(xx); The above is just simple method-chaining, without any sophisticated formal language definition. Most often in method-chaining contexts, the order of method calls is irrelevant … Continue reading jOOQ’s fluent API in BNF notation
The Java Fluent API Designer Crash Course
Ever since Martin Fowler's talks about fluent interfaces, people have started chaining methods all over the place, creating fluent API's (or DSLs) for every possible use case. In principle, almost every type of DSL can be mapped to Java. Let's have a look at how this can be done DSL rules DSLs (Domain Specific Languages) … Continue reading The Java Fluent API Designer Crash Course