Deleting query sort criterion causes exception

Topics: Administration, Customizing Orchard, Troubleshooting
Nov 6, 2012 at 12:31 PM

Hi,

This has something to do with the query i'm using, I've tried to replicate it on a clean install and I couldn't.

A bit of background, i'm using ZenGallery content type with a mediapicker field for a summary image (the image used in projections etc), the query's XML looks like:

<Query Id="/Identifier=ad9e3277b4ad47ec8ad2989e094dde76" Status="Published">
  <TitlePart Title="Outro portfolio" />
  <IdentityPart Identifier="ad9e3277b4ad47ec8ad2989e094dde76" />
  <QueryPart>
    <FilterGroups>
      <FilterGroup>
        <Filter Category="ZenGalleryContentFields" Description="" Position="0" State="&lt;Form&gt;&lt;Description&gt;&lt;/Description&gt;&lt;Operator&gt;NotEquals&lt;/Operator&gt;&lt;Value&gt;&lt;/Value&gt;&lt;__RequestVerificationToken&gt;w-SbymcdS4RAX-6mvplKhPsLvIhBl5wAkQAvaUHxCN-dwDGZ2ewL4QyR7tLKwMex6p3odL2Jwt84_6s8nqKlgwvQNDHxtw0mLeYCOSM38MZ8sVGWb9BmR7fHsLs7dr2RTkpPc5q3CiA_vRU2CKN2hbzB6Idd06-jfFPDBgCIQSs1&lt;/__RequestVerificationToken&gt;&lt;/Form&gt;" Type="ZenGallery.SummaryImage." />
      </FilterGroup>
    </FilterGroups>
    <SortCriteria>
      <SortCriterion Category="General" Description="" Position="0" State="" Type="Random" />
    </SortCriteria>
    <Layouts>
      <Layout Category="Html" Description="" State="&lt;Form&gt;&lt;QueryId&gt;34&lt;/QueryId&gt;&lt;Category&gt;Html&lt;/Category&gt;&lt;Type&gt;List&lt;/Type&gt;&lt;Description&gt;&lt;/Description&gt;&lt;Display&gt;0&lt;/Display&gt;&lt;DisplayType&gt;Summary&lt;/DisplayType&gt;&lt;Order&gt;unordered&lt;/Order&gt;&lt;ListId&gt;&lt;/ListId&gt;&lt;ListClass&gt;gallery&lt;/ListClass&gt;&lt;ItemClass&gt;&lt;/ItemClass&gt;&lt;__RequestVerificationToken&gt;Tdbiu4b4TMl3OqSSK2YmnF8saW09latKro9M85OgUGdrOH92a7GAEYeOIbLMtFojYG3Cp9DqE0D9NZehXINidBJNqtxxsKinLWU7ub971_mJADtSoqbhsMY9J_kJQnLWxVeYYhiwIXDQVGYlw7DdJQiJWCZVAg0F3qIi02-KBB01&lt;/__RequestVerificationToken&gt;&lt;/Form&gt;" Display="0" DisplayType="Summary" Type="List">
        <Properties />
        <Group />
      </Layout>
    </Layouts>
  </QueryPart>
</Query>

For everyone's sanity :) in the UI it looks like http://imageshack.us/photo/my-images/837/query.png/

Whenever I try to remove the sort critireon, to say, add another one, I get the following exception and the query is unusable, I can't edit, export or use it:

No row with the given identifier exists[Orchard.Projections.Models.SortCriterionRecord#2]

NHibernate.ObjectNotFoundException: No row with the given identifier exists[Orchard.Projections.Models.SortCriterionRecord#2] em NHibernate.Impl.SessionFactoryImpl.DefaultEntityNotFoundDelegate.HandleEntityNotFound(String entityName, Object id) em NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) em Orchard.Data.Providers.AbstractDataServicesProvider.OrchardLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) em NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) em NHibernate.Impl.SessionImpl.InternalLoad(String entityName, Object id, Boolean eager, Boolean isNullable) em NHibernate.Type.EntityType.ResolveIdentifier(Object id, ISessionImplementor session) em NHibernate.Collection.PersistentBag.InitializeFromCache(ICollectionPersister persister, Object disassembled, Object owner) em NHibernate.Cache.Entry.CollectionCacheEntry.Assemble(IPersistentCollection collection, ICollectionPersister persister, Object owner) em NHibernate.Event.Default.DefaultInitializeCollectionEventListener.InitializeCollectionFromCache(Object id, ICollectionPersister persister, IPersistentCollection collection, ISessionImplementor source) em NHibernate.Event.Default.DefaultInitializeCollectionEventListener.OnInitializeCollection(InitializeCollectionEvent event) em NHibernate.Impl.SessionImpl.InitializeCollection(IPersistentCollection collection, Boolean writing) em NHibernate.Collection.AbstractPersistentCollection.ReadSize() em NHibernate.Collection.PersistentBag.get_Count() em System.Linq.Buffer`1..ctor(IEnumerable`1 source) em System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext() em Orchard.Projections.Controllers.AdminController.Edit(Int32 id) em lambda_method(Closure , ControllerBase , Object[] ) em System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) em System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) em System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.<InvokeActionMethodWithFilters>b__10() em System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) em System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) em System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)

Any ideas?

Thanks

Nov 6, 2012 at 1:28 PM
Edited Nov 6, 2012 at 1:34 PM

Correct me if I'm wrong but your Query seems to be returning an Image or collection of images (screenshot of what is returned will help), if so there is no Identifier for the Sort criteria to be based on, I had thought.

For example, you Query to get all Page ContentItems in your site, and within the Page ContentType there's an Identifier to enable a sort criterion to be executed e.g. Date published/created/saved etc...

Hope that helps.

Nov 6, 2012 at 1:47 PM

It is returning the content types ZenGallery as expected, where the ZenGallery.SummaryImage is not empty, unless I'm misusing the Filters?

To be honest queries are still new to me, could it be that when no SortCriteria is defined it default's to the filter's, rather than the content type it returns?

Nov 6, 2012 at 2:04 PM

Wow, really strange, I went away on lunch, iis worker process restarted, and now I'm able to view the query! without throwing the exception or erroring! http://imageshack.us/photo/my-images/832/queryl.png/

Maybe cache/syscache issue, will investigate further..

Nov 6, 2012 at 2:09 PM

Yap, I can confirm with syscache module enable, deleting a sort criterion throws this exception, raising an issue now

Nov 6, 2012 at 2:11 PM

done, issue raised here: http://orchard.codeplex.com/workitem/19227

Feb 7, 2013 at 9:57 PM
Note. This problem also occurs when deleting a Filter from your query. Restarting IIS resolves the issue in this case too.