How to select a subset of tags with HQL

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to select a subset of tags with HQL

BrianJones
Hello again,

So my next dilema is structuring the 'All Tags' page.  Currently, there is a list of all tags on all pages on all spaces, in alphabetical order.  All good here.

However, the way I'm utilizing the tags, there are certain groups of tags that all have the same prefix, for example a group of tags that all start with 'xyz-', or another group that all starts with 'zyx-'.

So, I'm trying to build an HQL statement that just selects those tags that contain the prefix 'xyz-', for example.  The HQL I'm using to select ALL tags is as follows:

select distinct elements(prop.list) from BaseObject as obj, DBStringListProperty as prop where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' order by 1 asc

I've tried appending additional where clauses trying to just selec the tags with the 'xyz-' prefix wihtout any luck.  I've tried such things as:

... and prop.value LIKE 'xyz-%' ...
and prop.id.value LIKE 'xyz-%' ...
and obj.value LIKE 'xyz-%' ...
and obj.id.value LIKE 'xyz-%' ...


None of these seem to work however.  Does anyone have any suggestions or a workaround?  Any and all input is greatly appreciated.  Thank you in advance community!

Cheers
Reply | Threaded
Open this post in threaded view
|

Re: How to select a subset of tags with HQL

Sergiu Dumitriu-2
BrianJones wrote:

> Hello again,
>
> So my next dilema is structuring the 'All Tags' page.  Currently, there is a
> list of all tags on all pages on all spaces, in alphabetical order.  All
> good here.
>
> However, the way I'm utilizing the tags, there are certain groups of tags
> that all have the same prefix, for example a group of tags that all start
> with 'xyz-', or another group that all starts with 'zyx-'.
>
> So, I'm trying to build an HQL statement that just selects those tags that
> contain the prefix 'xyz-', for example.  The HQL I'm using to select ALL
> tags is as follows:
>
> select distinct elements(prop.list) from BaseObject as obj,
> DBStringListProperty as prop where obj.className='XWiki.TagClass' and
> obj.id=prop.id.id and prop.id.name='tags' order by 1 asc
>
> I've tried appending additional where clauses trying to just selec the tags
> with the 'xyz-' prefix wihtout any luck.  I've tried such things as:
>
> ... and prop.value LIKE 'xyz-%' ...
> and prop.id.value LIKE 'xyz-%' ...
> and obj.value LIKE 'xyz-%' ...
> and obj.id.value LIKE 'xyz-%' ...
>
> None of these seem to work however.  Does anyone have any suggestions or a
> workaround?  Any and all input is greatly appreciated.  Thank you in advance
> community!
>
> Cheers


select distinct tag from BaseObject as obj, DBStringListProperty as prop
join prop.list as tag where obj.className='XWiki.TagClass' and
obj.id=prop.id.id and prop.id.name='tags' and tag like 'xyz-%' order by
1 asc

--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users