Each node in a JCR workspace has a type. The type defines the child nodes and properties that the node may or must have. Magnolia uses node types to define a custom content model whereas Jackrabbit enforces the constraints of that model at the repository level. See Apache Jackrabbit Node Types for more information. Magnolia does not use the Jackrabbit JcrConstants as they are not comprised of both prefixes and suffixes. This has query limitations, for example if a NodeType starts with
MgnlNodeType.JCR_PREFIX. Magnolia node types are registered by the
Java class. Both prefixes and suffixes are defined.
Magnolia node types
Mixin node types
JCR primary type
JCR frozen node
JCR frozen primary type
Magnolia supports the SQL and JCR-SQL2 query languages. Although deprecated, XPath remains available and will be supported for the foreseeable future.
Query tools are available at Tools > JCR Queries.
The Dump tool creates a repository dump:
- Select a repository (workspace).
- Type a path.
- Select the number of levels.
- Click Execute
The results are displayed in the Result box. A dump returns all nodes in the JCR that comply with the selected criteria. Here are a few sample results for the above dump.
The Query tool executes the results of a specific query:
- Select the repository and the query language.
- Define the result ItemType, if any.
- Type the query in the main box.
- Click Execute.
The results are displayed in the Result box.
A few tips for writing and testing queries:
- Use the query tool to validate queries used in code.
- An incorrect query often returns empty results which complicates debugging
- Make your queries additive. Test the basics and then refine them to be more precise.
- Case insensitive searches are not supported. As workaround, ensure that both parts of the search condition use same case.
Here's a few sample queries in the SQL language. Apache.org has a handy translator tool that converts queries from SQL to XPath and vice versa. See the JCR Query cheat sheet on the wiki for more.
select * from mgnl:page
Pages in the About section
select * from mgnl:page where jcr:path like '/demo-project/about/%'
Pages with "News" in the title
select * from mgnl:page where title like '%News%'
Pages with "News" in the title (case sensitive)
select * from mgnl:content where title like 'News'
Pages that use a specific DMS image
select * from mgnl:content where imageDmsUUID='01d1b9bc-93e8-471f-96db-2c81855ce65d'
Pages that link to a contact
select * from nt:base where linkTitle like '%Contact%' and linkType='internal'
select * from nt:base where jcr:path like '/modules/%/components/%' and type is not null
User with email email@example.com
select * from mgnl:user where email = 'firstname.lastname@example.org'
Data categories that have related categories
select * from nt:base where jcr:path like '/categorization/%' and relatedUUID is not null
JPEG images in the DMS
select * from nt:base where type='jpg'