{"id":26528110,"url":"https://github.com/queritylib/querity","last_synced_at":"2025-12-26T01:39:05.289Z","repository":{"id":43845089,"uuid":"426922353","full_name":"queritylib/querity","owner":"queritylib","description":"Open-source Java query builder for SQL and NoSQL","archived":false,"fork":false,"pushed_at":"2025-07-01T13:42:37.000Z","size":828,"stargazers_count":47,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-03T12:57:32.858Z","etag":null,"topics":["database","elasticsearch","java","jpa","mongodb","nosql","query-builder","spring","spring-data","sql"],"latest_commit_sha":null,"homepage":"https://queritylib.github.io/querity/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/queritylib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["brunomendola"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-11-11T08:19:47.000Z","updated_at":"2025-07-01T13:42:34.000Z","dependencies_parsed_at":"2025-06-17T19:05:57.231Z","dependency_job_id":"02f440ef-57c3-49db-bbb7-ddfe1128521d","html_url":"https://github.com/queritylib/querity","commit_stats":null,"previous_names":["queritylib/querity"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/queritylib/querity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queritylib%2Fquerity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queritylib%2Fquerity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queritylib%2Fquerity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queritylib%2Fquerity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/queritylib","download_url":"https://codeload.github.com/queritylib/querity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queritylib%2Fquerity/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265971711,"owners_count":23857940,"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":["database","elasticsearch","java","jpa","mongodb","nosql","query-builder","spring","spring-data","sql"],"created_at":"2025-03-21T15:49:39.380Z","updated_at":"2025-12-26T01:39:05.283Z","avatar_url":"https://github.com/queritylib.png","language":"Java","readme":"\u003cimg alt=\"Querity-logo\" src=\"https://user-images.githubusercontent.com/1853562/142502086-2a352854-2315-4fe5-b1a3-d7730a47fe36.jpeg\" width=\"80\" height=\"80\"/\u003e Querity\n=======\n\n[![Build](https://github.com/queritylib/querity/actions/workflows/maven.yml/badge.svg)](https://github.com/queritylib/querity/actions/workflows/maven.yml)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=queritylib_querity\u0026metric=bugs)](https://sonarcloud.io/summary/new_code?id=queritylib_querity)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=queritylib_querity\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=queritylib_querity)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=queritylib_querity\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=queritylib_querity)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=queritylib_querity\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=queritylib_querity)\n[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/QuerityLib.svg?style=social\u0026label=Follow%20%40QuerityLib)](https://twitter.com/QuerityLib)\n\nOpen-source Java query builder for SQL and NoSQL.\n\n## Description\n\nQuerity is an extensible query builder to create and run database queries in your Java application.\n\nIt supports **SQL** and **NoSQL** databases technologies, and each support is built into small modules, so you\ncan import the one which fits into your project.\n\n### Features\n\nDatabase support:\n\n* any SQL database (with the JPA modules)\n* MongoDB\n* Elasticsearch\n\nQuery features:\n\n* filtering\n* sorting\n* pagination\n* projections (select specific fields)\n* textual query language\n* support for REST APIs\n* support for DTO layer\n* native database expressions (JPA)\n* and more...\n\nAll with ONE SINGLE LANGUAGE!\n\n## Documentation\n\nRead the full documentation [here](https://queritylib.github.io/querity).\n\n## Demo\n\nCheck out the simplest demo application using Querity at [querity-demo](https://github.com/queritylib/querity-demo).\n\nThis demo also uses the [@queritylib/react](https://github.com/queritylib/querity-react) library for the frontend. Take\na look!\n\n## Getting Started\n\n### Dependencies\n\n* Java 17+\n* Spring Framework 6 (optionally Spring Boot 3... makes things a lot simpler)\n\n### Installing\n\nAll releases are published to the Maven Central repository (\nsee [here](https://search.maven.org/search?q=io.github.queritylib)).\n\nAvailable modules:\n\n* **querity-spring-data-jpa**: supports Spring Data JPA\n* **querity-jpa**: supports plain Jakarta Persistence API (Spring not required)\n* **querity-spring-data-mongodb**: supports Spring Data MongoDB\n* **querity-spring-data-elasticsearch**: supports Spring Data Elasticsearch\n* **querity-spring-web**: supports JSON de/serialization of Querity objects in Spring Web MVC\n* **querity-parser**: enable the parsing of Querity objects from a **simple query language**\n\nAll Spring modules are \"Spring Boot starters\", you just need to add the dependency to your Spring Boot project and start using\nit, no other configuration needed.\n\nMaven:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.queritylib\u003c/groupId\u003e\n  \u003cartifactId\u003equerity-spring-data-jpa\u003c/artifactId\u003e\n  \u003cversion\u003e${querity.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nGradle:\n\n```groovy\nimplementation \"io.github.queritylib:querity-spring-data-jpa:${querityVersion}\"\n```\n\n### Usage\n\n```java\n\n\n@Service\npublic class MyService {\n\n  @Autowired\n  Querity querity;\n\n  public Result\u003cPerson\u003e getPeople() {\n    Query query = Querity.query()\n        // customize filters, pagination, sorting...\n        .filter(\n            not(and(\n                filterBy(\"lastName\", EQUALS, \"Skywalker\"),\n                filterBy(\"firstName\", EQUALS, \"Luke\")\n            ))\n        )\n        .sort(sortBy(\"lastName\"), sortBy(\"birthDate\", DESC))\n        .pagination(1, 10)\n        .build();\n    List\u003cPerson\u003e items = querity.findAll(Person.class, query);\n    Long totalCount = querity.count(Person.class, query.getFilter());\n    return new Result\u003c\u003e(items, totalCount);\n  }\n\n  record Result\u003cT\u003e(List\u003cT\u003e items, Long totalCount) {\n  }\n}\n```\n\nIn the above example, the `findAll` method returns the first of n pages with max 10 elements of all people NOT named\nLuke Skywalker, sorted by last name and then birthdate descending.\u003cbr /\u003e\nThe `count` method returns the total filtered items count excluding pagination (the record keyword is implemented from\nJava 14).\n\n\u003e Note the static imports to improve the readability.\n\n#### Projections\n\nUse `selectBy` to retrieve only specific fields instead of full entities:\n\n```java\nQuery query = Querity.query()\n    .selectBy(\"firstName\", \"lastName\", \"address.city\")\n    .filter(filterBy(\"lastName\", EQUALS, \"Skywalker\"))\n    .build();\nList\u003cMap\u003cString, Object\u003e\u003e results = querity.findAllProjected(Person.class, query);\n// Each map contains only: {firstName: \"...\", lastName: \"...\", city: \"...\"}\n```\n\n#### Native expressions (JPA only)\n\nFor advanced use cases, JPA modules support native expressions using `CriteriaBuilder`:\n\n**Native sort with expression:**\n\n```java\n// Sort by length of lastName\nOrderSpecification\u003cPerson\u003e orderSpec = (root, cb) -\u003e cb.asc(cb.length(root.get(\"lastName\")));\nQuery query = Querity.query()\n    .sort(sortByNative(orderSpec))\n    .build();\nList\u003cPerson\u003e results = querity.findAll(Person.class, query);\n```\n\n**Native select with expression:**\n\n```java\n// Select concatenated full name\nSelectionSpecification\u003cPerson\u003e fullNameSpec = AliasedSelectionSpecification.of(\n    (root, cb) -\u003e cb.concat(cb.concat(root.get(\"firstName\"), \" \"), root.get(\"lastName\")),\n    \"fullName\"\n);\nQuery query = Querity.query()\n    .select(selectByNative(fullNameSpec))\n    .build();\nList\u003cMap\u003cString, Object\u003e\u003e results = querity.findAllProjected(Person.class, query);\n// Each map contains: {fullName: \"Luke Skywalker\"}\n```\n\n\u003e Native expressions are only available for JPA. MongoDB and Elasticsearch support `sortByNative` and `filterByNative` with their respective native types (`Order`, `Criteria`), but not expression-based projections.\n\n#### Query language\n\nThe `querity-parser` module provides a simple query language to build a `Query` object,\nuseful when you need the user to write and understand the query.\n\nIt is an alternative approach to the one provided by the module `querity-spring-web`, which parses JSON.\n\nThe following snippet rewrites the previous example using the query language:\n\n```java\nimport io.github.queritylib.querity.api.Query;\nimport io.github.queritylib.querity.parser.QuerityParser;\n\n//...\n\npublic List\u003cPerson\u003e getPeople() {\n  Query query = QuerityParser.parseQuery(\"not(and(lastName=\\\"Skywalker\\\", firstName=\\\"Luke\\\")) sort by lastName, birthDate desc page 1,10\");\n  return querity.findAll(Person.class, query);\n}\n\n//...\n```\n\n## Access to SNAPSHOT builds\n\nCommits to the `main` branch are automatically built and deployed to Central Portal Snapshots Maven repository.\n\nTo use the SNAPSHOTs in your project, add the SNAPSHOTs repository as follows.\n\n\u003e Of course using SNAPSHOTs is not recommended, but if you feel brave you can do it to test new not-yet-released features.\n\nMaven:\n\n```xml\n\u003crepositories\u003e\n  \u003crepository\u003e\n    \u003cname\u003eCentral Portal Snapshots\u003c/name\u003e\n    \u003cid\u003ecentral-portal-snapshots\u003c/id\u003e\n    \u003curl\u003ehttps://central.sonatype.com/repository/maven-snapshots/\u003c/url\u003e\n    \u003creleases\u003e\n      \u003cenabled\u003efalse\u003c/enabled\u003e\n    \u003c/releases\u003e\n    \u003csnapshots\u003e\n      \u003cenabled\u003etrue\u003c/enabled\u003e\n    \u003c/snapshots\u003e\n  \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nGradle:\n\n```groovy\nrepositories {\n  // ...\n  maven {\n    name = 'Central Portal Snapshots'\n    url = 'https://central.sonatype.com/repository/maven-snapshots/'\n    mavenContent { snapshotsOnly() }\n  }\n  // ...\n}\n```\n\nBrowse the\nrepository [here](https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/io/github/queritylib/querity-parent/)\nto find the latest SNAPSHOT version.\n\n## Development\n\n### Running tests\n\nRun with Maven (wrapper):\n\n```bash\n./mvnw test\n```\n\nor just run them with your favourite IDE.\n\n### Test dataset\n\nThe test dataset is generated with [Mockaroo](https://mockaroo.com).\n\nIf you want to make changes, you don't need to do it manually, please find the\nschema [here](https://mockaroo.com/ec155390).\n\n## Authors\n\nContributors names and contact info\n\n* Bruno Mendola [@brunomendola](https://github.com/brunomendola)\n\n**PRs are welcome!**\n\n## Version History\n\nSee [Releases](https://github.com/queritylib/querity/releases).\n\n## License\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details\n","funding_links":["https://github.com/sponsors/brunomendola"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueritylib%2Fquerity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqueritylib%2Fquerity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueritylib%2Fquerity/lists"}