[xwiki-users] multi-select property xwql quering
Hello! I need help with xwql quering. I have my own class with property tMembers with type="user list" also this property is a multi-select. How is possible to query all docs of this class with filter for some user? If no multiselect - all is easy: #set($xwlquery="from doc.object($class) as obj where doc.fullName <> '$template' and obj.tStatus='2' and obj.tMembers='$usedUser' order by doc.date desc") If multiselect switched on, but only one user selected - also this query working. But, when used multiselect (selected 2 users) this query not working. Also I tryed - obj.tMembers like '$usedUser' and - obj.tMembers.content like '$usedUser' - no result. -- Thanks beforehand! Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/multi-select-property-xwql-quering-tp75816... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hello, I did not test the following, but in this case obj.tMembers is not a simple value but a list. You could try something like '$usedUser' member of obj.tMembers Br, Jeremie 2012/10/8 Eugen Colesnicov <[email protected]>:
Hello! I need help with xwql quering.
I have my own class with property tMembers with type="user list" also this property is a multi-select. How is possible to query all docs of this class with filter for some user?
If no multiselect - all is easy: #set($xwlquery="from doc.object($class) as obj where doc.fullName <> '$template' and obj.tStatus='2' and obj.tMembers='$usedUser' order by doc.date desc")
If multiselect switched on, but only one user selected - also this query working. But, when used multiselect (selected 2 users) this query not working.
Also I tryed - obj.tMembers like '$usedUser' and - obj.tMembers.content like '$usedUser' - no result.
-- Thanks beforehand! Eugen Colesnicov
-- View this message in context: http://xwiki.475771.n2.nabble.com/multi-select-property-xwql-quering-tp75816... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Thanks! but unfortunatly vairant jerem wrote
'$usedUser' member of obj.tMembers
doesn't work ... I got an error: ... Caused by: org.xwiki.query.QueryException: Exception while execute query. Query statement = [ select doc.fullName from XWikiDocument as doc , BaseObject as obj , com.xpn.xwiki.objects.StringProperty as obj_tStatus1, com.xpn.xwiki.objects.LargeStringProperty as obj_tMembers2 where ( doc.fullName <> 'etvcPlanningsCode.tClassTemplate' and obj_tStatus1.value = '2' and 'XWiki.Admin' in elements( obj_tMembers2.value ) ) and doc.fullName=obj.name and obj.className='etvcPlanningsCode.tClass' and obj_tStatus1.id.id=obj.id and obj_tStatus1.id.name='tStatus' and obj_tMembers2.id.id=obj.id and obj_tMembers2.id.name='tMembers' order by doc.date desc ] ... Caused by: com.xpn.xwiki.XWikiException: Error number 0 in 3: Exception while hibernate execute Wrapped Exception: null ... Full error log in attachment err.txt <http://xwiki.475771.n2.nabble.com/file/n7581696/err.txt> -- Best regards Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/multi-select-property-xwql-quering-tp75816... Sent from the XWiki- Users mailing list archive at Nabble.com.
Sorry that's right, it's not mapped as a list but as a comma separated string. Your approach with 'like' should work but you miss the % : obj.tMembers like '%${usedUser}%' 2012/10/8 Eugen Colesnicov <[email protected]>:
Hello! I need help with xwql quering.
I have my own class with property tMembers with type="user list" also this property is a multi-select. How is possible to query all docs of this class with filter for some user?
If no multiselect - all is easy: #set($xwlquery="from doc.object($class) as obj where doc.fullName <> '$template' and obj.tStatus='2' and obj.tMembers='$usedUser' order by doc.date desc")
If multiselect switched on, but only one user selected - also this query working. But, when used multiselect (selected 2 users) this query not working.
Also I tryed - obj.tMembers like '$usedUser' and - obj.tMembers.content like '$usedUser' - no result.
-- Thanks beforehand! Eugen Colesnicov
-- View this message in context: http://xwiki.475771.n2.nabble.com/multi-select-property-xwql-quering-tp75816... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Variant: jerem wrote
obj.tMembers like '%${usedUser}%'
working great! Thanks a lot! Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/multi-select-property-xwql-quering-tp75816... Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (2)
-
Eugen Colesnicov -
Jeremie BOUSQUET