Lambda2sql
Convert Java lambdas to SQL statements. Build type safe and readable queries.
Install / Use
/learn @ajermakovics/Lambda2sqlREADME
Lambda2sql (lambda) -> "sql"
Convert Java 8 lambdas to SQL statements.
For example, the following Predicate<Person>:
person -> person.getAge() < 100 && person.getHeight() > 200
is converted to a string:
age < 100 AND height > 200
allowing you to write readable queries in a type safe way.
See Lambda2SqlTest for more examples or the Wiki.
Usage
int age = 100;
int height = 200;
SqlPredicate<Person> predicate = person -> person.getAge() < age && person.getHeight() > height;
String sql = Lambda2Sql.toSql(predicate); // age < 100 AND height > 200
How it works
It uses JaQue to build an expression tree for a lambda. The expression tree is then traversed and converted to a SQL statement.
Under the hood, JaQue depends on the system property jdk.internal.lambda.dumpProxyClasses, if the lambda expression is not serialized:
See https://bugs.openjdk.java.net/browse/JDK-8023524.
When the property is enabled, JVM generated classes for lambdas are saved to disk. JaQue then uses ASM to read the .class files and creates expression trees.
Since the interface SqlPredicate<T> is automatically serialized, there is no need to set this property.
Limitations
Current version only works with predicates and supports the following operators: >, >=, <, <=, =, !=, &&, ||, !
Install
You can get the library using JitPack https://jitpack.io/#ajermakovics/lambda2sql/0.7
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.ajermakovics:lambda2sql:0.7'
}
Build
gradle jar or gradle fatjar to include dependencies.
Related Skills
oracle
342.0kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
prose
342.0kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
Command Development
84.7kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
Plugin Structure
84.7kThis skill should be used when the user asks to "create a plugin", "scaffold a plugin", "understand plugin structure", "organize plugin components", "set up plugin.json", "use ${CLAUDE_PLUGIN_ROOT}", "add commands/agents/skills/hooks", "configure auto-discovery", or needs guidance on plugin directory layout, manifest configuration, component organization, file naming conventions, or Claude Code plugin architecture best practices.
