Missing entries from suggestion box of Page-type attributes with hibernate query

Hello :slight_smile:

I have a class which contains an attribute named “food” of the type “Page”. It has the ‘Use Suggest’ checkbox clicked, the ‘Relational Storage’ checkbox and the following Hibernate Query in which I try to find all pages containing objects of some other classes of mine.

, BaseObject as obj where doc.fullName = obj.name and ( obj.className = 'Diät.Code.IngridientClass' or obj.className = 'Diät.Code.Food Class' ) and not doc.fullName like '%.Code.%'

The suggestion box doesn’t suggest some of the newly pages I created and added objects to:
failed-suggest

Other queries for older pages work fine. When I copy the exact same query into a page however, the pages do show up. For example, the following query

{{velocity}}
$services.query.hql(", BaseObject as obj where doc.fullName = obj.name and ( obj.className = 'Diät.Code.IngridientClass' or obj.className = 'Diät.Code.Food Class' ) and not doc.fullName like '%.Code.%'").execute()
{{/velocity}}

yields the following result:
working-query

When I delete the hibernate query from the attribute of my class, everything works as expected:

working-suggest

I don’t think this is a UI/Browser-Cache-Problem. I’ve already cleared the cache, used a private window and the missing pages are not showing up in the request at rest/wikis/xwiki/classes/Diät.Code.Meal Class/properties/food/values?fp=Mystery&limit=10 in the network tab of my browser, which only yields:

{
  "links": [
    {
      "href": "http://127.0.0.1:10010/rest/wikis/xwiki/classes/Di%C3%A4t.Code.Meal%20Class/properties/food",
      "rel": "http://www.xwiki.org/rel/property",
      "type": null,
      "hrefLang": null
    }
  ],
  "propertyValues": []
}

Is there a cache for hibernate queries which needs to be refreshed? If so, how do I do that? Am I doing something else wrong?

I appreciate any help you can offer.

Greetings from Germany,
Felix Herrmann

The issue is with this part of the query:

and not doc.fullName like '%.Code.%'

It should be instead:

and doc.fullName not like '%.Code.%'

but even if you use this it won’t work because of 'not like' where clause not correct · Issue #726 · JSQLParser/JSqlParser · GitHub . This is going to be fixed in XWiki 10.11.1 and 11.0RC1, see Loading... . See also the comments from Loading... which is caused by the same JSQLParser issue.

The workaround for you is to not use “not like” to exclude the templates but rely instead on the hidden flag. The template pages should be hidden so you can use:

, BaseObject as obj where doc.fullName = obj.name and ( obj.className = 'Diät.Code.IngridientClass' or obj.className = 'Diät.Code.Food Class' ) and (doc.hidden <> true or doc.hidden is null)

Hope this helps,
Marius

Hi Marius,

Thank you so much. It would have taken me ages to find this.
I tried your approach, it seemed to work so I marked the thread solved.

Greetings
Felix