You can use this code: http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsfro... "## if you have more than one object on a page, you will have to loop over them and use "$doc.use"" Pascal BASTIEN -------------------------------------------- En date de : Mer 13.7.16, Thomas Mortagne <[email protected]> a écrit : Objet: Re: [xwiki-users] hql query returning objects? À: "XWiki Users" <[email protected]> Date: Mercredi 13 juillet 2016, 7h56 On Tue, Jul 12, 2016 at 7:03 PM, dullfig <[email protected]> wrote:
Hello:
I have a problem. I created an XClass with personal info (name, address etc); but instead of attaching one XObject to many pages (1 to 1), I have attached many objects of the same class to one single page (an array of
xobjects if you will). Is it possible to query the xobjects for a particular
name, and have the query return an xobject, instead of the name of the page? the name of the page does me no good, because I still have to search through
the objects...
doing:
#set( $hql
= "select obj.name from BaseObject obj where obj.className =
'$class.name'" )
returns a list containing the same page
over and over, instead of a list of
xobjects.
Can this
be done? You can't directly get an XObject from a hql request but you can get enough information to get the object from the document. obj.name is indeed the name of the page, you already know the class name so what is missing for you is the obj.number. Then you can do $xwiki.getDocument($name).getObject($classs.name, $number)
Dan
-- View this message in context: http://xwiki.475771.n2.nabble.com/hql-query-returning-objects-tp7600307.html Sent from the XWiki- Users mailing list
archive at Nabble.com.
_______________________________________________
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users