{"id":17194909,"url":"https://github.com/ajermakovics/lambda2sql","last_synced_at":"2025-04-13T19:31:58.275Z","repository":{"id":23177276,"uuid":"26533323","full_name":"ajermakovics/lambda2sql","owner":"ajermakovics","description":"Convert Java lambdas to SQL statements. Build type safe and readable queries.","archived":false,"fork":false,"pushed_at":"2020-04-10T13:13:26.000Z","size":25,"stargazers_count":65,"open_issues_count":1,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-27T10:21:21.016Z","etag":null,"topics":["java","lambda","orm","sql"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajermakovics.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-12T11:41:44.000Z","updated_at":"2025-03-24T13:46:11.000Z","dependencies_parsed_at":"2022-07-07T20:24:28.759Z","dependency_job_id":null,"html_url":"https://github.com/ajermakovics/lambda2sql","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajermakovics%2Flambda2sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajermakovics%2Flambda2sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajermakovics%2Flambda2sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajermakovics%2Flambda2sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajermakovics","download_url":"https://codeload.github.com/ajermakovics/lambda2sql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248767972,"owners_count":21158567,"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":["java","lambda","orm","sql"],"created_at":"2024-10-15T01:48:36.714Z","updated_at":"2025-04-13T19:31:57.965Z","avatar_url":"https://github.com/ajermakovics.png","language":"Java","readme":"Lambda2sql (lambda) -\u003e \"sql\"\n==========\n\n[![](https://jitpack.io/v/ajermakovics/lambda2sql.svg)](https://jitpack.io/#ajermakovics/lambda2sql)\n\nConvert Java 8 lambdas to SQL statements.\n\nFor example, the following Predicate\u003cPerson\u003e:\n```jshelllanguage\n person -\u003e person.getAge() \u003c 100 \u0026\u0026 person.getHeight() \u003e 200\n```\n \nis converted to a string:\n \n```\n  age \u003c 100 AND height \u003e 200\n```\nallowing you to write readable queries in a type safe way.\n\nSee [Lambda2SqlTest](https://github.com/ajermakovics/lambda2sql/blob/master/src/test/java/lambda2sql/Lambda2SqlTest.java) for more examples or the [Wiki](https://github.com/ajermakovics/lambda2sql/wiki).\n\t\nUsage\n---------\n\n```jshelllanguage\nint age = 100;\nint height = 200;\nSqlPredicate\u003cPerson\u003e predicate = person -\u003e person.getAge() \u003c age \u0026\u0026 person.getHeight() \u003e height;\n\nString sql = Lambda2Sql.toSql(predicate); // age \u003c 100 AND height \u003e 200\n```\n\n\nHow it works\n---------\n\nIt uses [JaQue](https://github.com/TrigerSoft/jaque) to build an expression tree for a lambda. The expression tree is then traversed and converted to a SQL statement. \n\nUnder the hood, JaQue depends on the system property `jdk.internal.lambda.dumpProxyClasses`, if the lambda expression is not serialized:\nSee [https://bugs.openjdk.java.net/browse/JDK-8023524](https://bugs.openjdk.java.net/browse/JDK-8023524).\n\nWhen the property is enabled, JVM generated classes for lambdas are saved to disk. JaQue then uses [ASM](http://asm.ow2.org/) to read the .class files and creates expression trees.\n\nSince the interface [`SqlPredicate\u003cT\u003e`](https://github.com/ajermakovics/lambda2sql/blob/master/src/main/java/lambda2sql/SqlPredicate.java) is automatically serialized, there is no need to set this property.\n\nLimitations\n---------\n\nCurrent version only works with predicates and supports the following operators: \u003e, \u003e=, \u003c, \u003c=, =, !=, \u0026\u0026, ||, !\n\nInstall\n-------\n\nYou can get the library using JitPack https://jitpack.io/#ajermakovics/lambda2sql/0.7\n\n```gradle\nrepositories {\n    maven { url \"https://jitpack.io\" }\n}\ndependencies {\n    compile 'com.github.ajermakovics:lambda2sql:0.7'\n}\t\n```\n\nBuild\n---------\n\n`gradle jar` or `gradle fatjar` to include dependencies.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajermakovics%2Flambda2sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajermakovics%2Flambda2sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajermakovics%2Flambda2sql/lists"}