WCM Workspace findByName(DocumentTypes.SiteArea, “”) or findByType(DocumentTypes.SiteArea) does not return root level items

When you are developing using the custom WCM API, espcially where I am using 8.0.0.1, I could not get to the root level site areas at all using the above methods. It was driving me crazy when I went in detail through the documentation where they have mentioned this work around.

Use the following method and it will work to get to the root Site Areas.

QueryService queryService = workspace.getQueryService();

Query query = queryService.createQuery(SiteArea.class);
query.addSelector(Selectors.nameLike(“SA_%”));
ResultIterator results = queryService.execute(query);

Hope this works for others.