DBList + Input + Suggest + HQL

I’ve got a Person Class with a lot of entries, which I reference from other classes with the following setting:

Display Type: input
Use Suggest: Yes
XWiki Class Name: App.Person.Code.PersonClass
Id Field Name: person_o_id
Value Field Name: person_o_display

Works like a charm! The ID is stored, the display name is displayed. When editing the field I can either start entering a persons ID or its display name, get a list of the display names of the matching persons and can select the one I was looking for.

Now I’d like to be able to replace this by a hibernate query, which would give me more control on the selection. I tried:

Display Type: input
Use Suggest: Yes
Hibernate Query: select p1.value, p2.value from BaseObject as o, StringProperty as p1, StringProperty as p2 where o.className = ‘App.Person.Code.PersonClass’ and p1.id.id = o.id and p1.id.name = ‘person_o_id’ and p2.id.id = o.id and p2.id.name = ‘person_o_display’

When I edit the field with these setting, only a subset of person entries is loaded and Suggest only works on this pre-loaded set. Entering the name of a person not in the subset won’t trigger a reload of selection set.

Any idea how I could make this work? I tried this with XWiki 10.2

Thanks
Guido

Solved. That’s confessional debugging :slight_smile:

I’ve got line-breaks in my query to make the HQL more readable. When I remove the line-breaks Suggest works as expected.

:slight_smile:

Glad you found the solution.