Re: [xwiki-users] select objects by class and sort by property
Sorry, that's not quite what I meant. My example wasn't very clear. Let's assume the class Photos.PhotoClass has a property called "location" indicating where the photo was taken. I'd like to be able to sort by that "location" property.
You can try
#set ($sql = ", BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.name=doc.fullName and obj.className='Photos.PhotoClass' and obj.name<>'Photos.PhotoClassTemplate' and obj.id=prop.id.id and prop.id.name='category' and list='${category}' order by doc.creationDate") or #set ($sql = ", BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.name=doc.fullName and obj.className='Photos.PhotoClass' and obj.name<>'Photos.PhotoClassTemplate' and obj.id=prop.id.id and prop.id.name='category' and list='${category}' order by doc.date")
depending if you want to sort by the creation date or update date of the documents
-- "Any sufficiently advanced technology is indistinguishable from magic." -- Arthur C. Clarke -- Brian D. Switzer email: herkamur [at] canada [dot] com web: http://bswitzer.railfan.net/
Hi, Ok you need to add this property in the query #set ($sql = ", BaseObject as obj, DBStringListProperty as prop join prop.list list, StringProperty as locprop join obj.id=locprop.id.id and locprop.id.name='location' where obj.name=doc.fullName and obj.className='Photos.PhotoClass' and obj.name<>'Photos.PhotoClassTemplate' and obj.id=prop.id.id and prop.id.name='category' and list='${category}' order by locprop.value") Ludovic Brian D. Switzer a écrit :
Sorry, that's not quite what I meant. My example wasn't very clear. Let's assume the class Photos.PhotoClass has a property called "location" indicating where the photo was taken. I'd like to be able to sort by that "location" property.
You can try
#set ($sql = ", BaseObject as obj, DBStringListProperty as prop join
prop.list list where obj.name=doc.fullName and obj.className='Photos.PhotoClass' and obj.name<>'Photos.PhotoClassTemplate' and obj.id=prop.id.id and prop.id.name='category' and list='${category}' order by doc.creationDate")
or #set ($sql = ", BaseObject as obj, DBStringListProperty as prop join
prop.list list where obj.name=doc.fullName and obj.className='Photos.PhotoClass' and obj.name<>'Photos.PhotoClassTemplate' and obj.id=prop.id.id and prop.id.name='category' and list='${category}' order by doc.date")
depending if you want to sort by the creation date or update date of the
documents
------------------------------------------------------------------------
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
-- Ludovic Dubost XPertNet: http://www.xpertnet.fr/ Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost AIM: nvludo Yahoo: ludovic
participants (2)
-
Brian D. Switzer -
Ludovic Dubost