If your main task is to run SQL (or SQLesque) statements in your custom Java H2 functions, jOOQ may be like a โPL / Javaโ implementation . Of course, this would still be a Java solution.
An example of such a function can be seen in this blog post:
http://blog.jooq.org/2011/11/04/use-jooq-inside-your-h2-database
public class Functions { public static int countBooks(Connection connection, Integer authorId) throws SQLException {
Declare the above method as ALIAS for H2
CREATE ALIAS countBooks FOR "org.example.Functions.countBooks";
Use function in SQL
SELECT author.last_name, countBooks(author.id) FROM author
A similar approach can be taken with JaQu's own SQL abstraction , of course. I think using JaQu would not add any extra dependency.
source share