Thank you, Sergiu! Directly after I sent my post, it
clicked in my head.
I did indeed fail to perform the joins. What I have now is:
#set($sql = ", BaseObject as obj, IntegerProperty as prop where obj.name =
doc.fullName and obj.className = 'Sensor Types.SensorTypeClass' and obj.name
<> 'Sensor Types.SensorTypeTemplate' and obj.id=prop.id.id and
prop.id.name='TypeID'
and prop.value >0 order by prop.value asc ")
And it works exactly as I've been trying to make it work.
Thanks again for your quick reply! :D
On Wed, Aug 27, 2014 at 12:49 PM, Sergiu Dumitriu wrote:
On 08/27/2014 03:29 PM, Dale Davidson wrote:
Hello there, I've been banging my head
against the desk a few days now
over this. I just can't find the answer online anywhere.
I'd like to perform an HQL query and use a number property of an object
on
each document to sort my results. I understand
SQL very well, but I just
need to know the object/property stucture -- exact syntax -- to use as
the
order by argument. I followed the FAQ tutorial to
create my class
systeem,
and it all works fine, but I need to be able to
display the
records/objects
in order.
What I have:
#set($sql = ", BaseObject as obj, IntegerProperty as prop where obj.name
=
doc.fullName and obj.className = 'Sensor
Types.SensorTypeClass' and
obj.name
<> 'Sensor
Types.SensorTypeTemplate' order by ??? asc")
prop is not joined in the query, this means you're getting horrible
performance if this is indeed your query. Perhaps that's your question,
what to write to get this property in the query? Is this what you're
looking for:
#set($sql = ", BaseObject as obj, IntegerProperty as prop where obj.name
= doc.fullName and obj.className = 'Sensor Types.SensorTypeClass' and
obj.name <> 'Sensor Types.SensorTypeTemplate'
and prop.id.id = obj.id and prop.id.name = 'TypeID' order by prop.value
asc")
In general you join properties with prop.id.id=obj.id, check the
property name with prop.id.name='propName', and get the value with
prop.value but this last part isn't always like this, there are two
exceptions:
- StringLists with multiple=true and relational=false use prop.textValue
- StringLists with multiple=true and relational=true use prop.list, but
you usually have to write:
, DBStringListProperty prop join prop.list list [...] prop.id.name =
'propName' and list = 'value'
...except for the ??? of course. I've tried many things, but I can't
figure out the structure I need to place there.
The property I need to sort by is "TypeID" and is attached to the
SensorTypeClass, and is an integer.
Thanks in advance for any help anyone could lend me :)
--
Sergiu Dumitriu
http://purl.org/net/sergiu
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org