I'm trying to run a very simple Query at the broker database. This example should get all pages from the broker.
ItemTypeCriteria criteria = new ItemTypeCriteria(64); // Page
Query query = new Query(criteria);
IItem[] results = query.ExecuteEntityQuery();
return results.Length;
When debugging this code, I see that the call to ExecuteEntityQuery
throws a NullReferenceException!
If I just use ExecuteQuery
:
ItemTypeCriteria criteria = new ItemTypeCriteria(64); // Page
Query query = new Query(criteria);
string[] results = query.ExecuteQuery();
return results.Length;
the result of ExecuteQuery
itself is null
.
In the same project on the same server I am successfully using a ComponentPresentationFactory so I would think my server is configured correctly.
Is there something wrong with my simple example? I would expect it to return the number of pages. I am wondering though why you don't seem to have to supply a publication id anywhere.
Based on Nickoli Roussakov's 1st remark, I've checked the logfile and it does show errors:
2014-08-11 12:42:24,641 ERROR Query - Unable to Configure for BrokerQuerying, query DAO could not be retrieved
com.tridion.broker.StorageException: No Data Access Object for Query
at com.tridion.storage.filesystem.FSDAOFactory.getDAOForTypeMapping(FSDAOFactory.java:181) ~[cd_datalayer.jar:na]
at com.tridion.storage.StorageManagerFactory.getOriginalDAO(StorageManagerFactory.java:500) ~[cd_datalayer.jar:na]
at com.tridion.storage.StorageManagerFactory.getDAO(StorageManagerFactory.java:269) ~[cd_datalayer.jar:na]
at com.tridion.storage.StorageManagerFactory.getDefaultDAO(StorageManagerFactory.java:176) ~[cd_datalayer.jar:na]
at com.tridion.broker.querying.Query.<init>(Query.java:45) [cd_broker.jar:na]
at com.tridion.broker.querying.Query.<init>(Query.java:59) [cd_broker.jar:na]
2014-08-11 12:42:24,657 ERROR Query - Unable to execute Broker Query, no QueryGenerator was initialized
So I guess the basic error is
com.tridion.broker.StorageException: No Data Access Object for Query
But what does it mean?
My complete class, including code that successfully renders a dynamic component presentation:
using Tridion.ContentDelivery.DynamicContent;
using Tridion.ContentDelivery.DynamicContent.Query;
namespace DFZ.Tridion.Mvc
{
public static class TridionDynamicContent
{
public static int GetNumberOfComponents()
{
ItemTypeCriteria criteria1 = new ItemTypeCriteria(64); // Page
Query query = new Query(criteria1);
string[] results = query.ExecuteQuery();
return results.Length;
}
public static ComponentPresentation GetComponentPresentation()
{
var cpf = new ComponentPresentationFactory(22);
return cpf.GetComponentPresentation(16604, 16632);
}
}
}
query
but trying to callExecuteEntityQuery
withquery1
object. Check ifquery1
variable decalred somewhere else without being initialized?