{"id":23498187,"url":"https://github.com/vpro/jcr-criteria","last_synced_at":"2025-10-28T18:37:12.516Z","repository":{"id":27077865,"uuid":"30544439","full_name":"vpro/jcr-criteria","owner":"vpro","description":"JCR queries using Java code","archived":false,"fork":false,"pushed_at":"2024-08-14T09:03:41.000Z","size":751,"stargazers_count":16,"open_issues_count":0,"forks_count":5,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-15T16:15:44.264Z","etag":null,"topics":["jackrabbit","jcr","magnolia","magnolia-cms","magnolia-component"],"latest_commit_sha":null,"homepage":"","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/vpro.png","metadata":{"files":{"readme":"README.adoc","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-09T16:07:46.000Z","updated_at":"2025-04-09T10:10:12.000Z","dependencies_parsed_at":"2022-08-17T22:15:17.494Z","dependency_job_id":"9073c15b-19bc-41a8-b621-bc792a445e67","html_url":"https://github.com/vpro/jcr-criteria","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpro%2Fjcr-criteria","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpro%2Fjcr-criteria/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpro%2Fjcr-criteria/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpro%2Fjcr-criteria/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vpro","download_url":"https://codeload.github.com/vpro/jcr-criteria/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249105471,"owners_count":21213535,"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":["jackrabbit","jcr","magnolia","magnolia-cms","magnolia-component"],"created_at":"2024-12-25T05:28:56.233Z","updated_at":"2025-10-28T18:37:12.434Z","avatar_url":"https://github.com/vpro.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= jcr-criteria\n\nimage:https://img.shields.io/maven-central/v/nl.vpro/jcr-criteria.svg?label=Maven%20Central[Maven Central,link=https://search.maven.org/search?q=g:%22nl.vpro%22%20AND%20a:%22jcr-criteria%22]\nimage:http://www.javadoc.io/badge/nl.vpro/jcr-criteria.svg?color=blue[javadoc,link=http://www.javadoc.io/doc/nl.vpro/jcr-criteria]\nimage:https://github.com/vpro/jcr-criteria/workflows/build/badge.svg?[Build Status,link=https://github.com/vpro/jcr-criteria/actions?query=workflow%3Abuild]\nimage:https://img.shields.io/nexus/s/https/oss.sonatype.org/nl.vpro/jcr-criteria.svg[snapshots,link=https://oss.sonatype.org/content/repositories/snapshots/nl/vpro/jcr-criteria/]\nimage:https://codecov.io/gh/vpro/jcr-criteria/branch/main/graph/badge.svg[codecov,link=https://codecov.io/gh/vpro/jcr-criteria]\n\nThis is a way to create and execute JCR queries using Java code, using an interface which was inspired by the Criteria API as used by Hibernate/JPA. This code is based on the http://www.openmindlab.com/lab/products/mgnlcriteria.html[Criteria API for Magnolia CMS] (openutils-mgnlcriteria) module which was developed by Openmind.\n\nIn contrast to `openutils-mgnlcriteria` there is no dependency on any Magnolia CMS code in `jcr-criteria`, so this is a generic JCR Criteria API implementation. It can still be used with Magnolia CMS, but should work with other JCR-based projects as well.\n\n== Usage\n\nYou can download the most recent jar from https://oss.sonatype.org/content/repositories/snapshots/nl/vpro/jcr-criteria/ or you can add this to your `pom.xml`:\n\n[source,xml]\n----\n\u003cdependency\u003e\n    \u003cgroupId\u003enl.vpro\u003c/groupId\u003e\n    \u003cartifactId\u003ejcr-criteria\u003c/artifactId\u003e\n    \u003cversion\u003e2.11\u003c/version\u003e\n\u003c/dependency\u003e\n\n----\n\nExample:\n\n[source,java]\n----\nimport nl.vpro.jcr.criteria.query.AdvancedResult;\nimport nl.vpro.jcr.criteria.query.AdvancedResultItem;\nimport nl.vpro.jcr.criteria.query.Criteria;\nimport nl.vpro.jcr.criteria.query.JCRCriteriaFactory;\nimport nl.vpro.jcr.criteria.query.criterion.Criterion;\nimport nl.vpro.jcr.criteria.query.criterion.Restrictions;\n\n..\n\nCriteria criteria = JCRCriteriaFactory.createCriteria()\n            .setBasePath(basePath)\n            .setPaging(1, 1)\n            .addOrder(Order.ascending(field))\n            .add(Restrictions.eq(Criterion.JCR_PRIMARYTYPE, NodeTypes.Page.NAME))\n            .add(Restrictions.in(\"@\" + NodeTypes.Renderable.TEMPLATE, templates))\n            .add(Restrictions.gt(field, begin));\n\n AdvancedResult ar = criteria.execute(MgnlContext.getJCRSession(RepositoryConstants.WEBSITE));\n log.debug(\"JCR query : \" + criteria.toXpathExpression());\n AdvancedResultItem item = ar.getFirstResult();\n\n----\n\nIt can also be done, if you prefer, using the builder pattern\n\n[source,java]\n----\n\nstatic import nl.vpro.jcr.criteria.query.criterion.Restrictions.*;\n\nExecutableQuery criteria = JCRCriteriaFactory.builder()\n            .basePath(basePath)\n            .order(Order.ascending(field))\n            .add(eq(Criterion.JCR_PRIMARYTYPE, NodeTypes.Page.NAME))\n            .add(in(attr(NodeTypes.Renderable.TEMPLATE), templates))\n            .add(gt(field, begin))\n            .build()\n            ;\nAdvancedResult result = criteria.execute(session);\n----\n\n== Java 11 and higher\n\nThis project is shipped (since 2.2) with a `module-info.java` which is though the only file compiled with java 11. The rest is compiled with java 8, so it is java 8 compatible, but it does participate in jigsaw if you happen to use java 11 already.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvpro%2Fjcr-criteria","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvpro%2Fjcr-criteria","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvpro%2Fjcr-criteria/lists"}