[xwiki-users] hql query returning objects?
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? 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.
On Tue, Jul 12, 2016 at 7:03 PM, dullfig <dan.u@grmcompany.com> 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 users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
great! I was hoping there was a way to address an object similar to using an array[] type. Dan -----Original Message----- From: Thomas Mortagne Sent: Tuesday, July 12, 2016 10:56 PM To: XWiki Users Subject: Re: [xwiki-users] hql query returning objects? On Tue, Jul 12, 2016 at 7:03 PM, dullfig <dan.u@grmcompany.com> 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 users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Thank you Thomas, I'll try. Regards,Julio De: Thomas Mortagne <thomas.mortagne@xwiki.com> Para: XWiki Users <users@xwiki.org> Enviadas: Quarta-feira, 13 de Julho de 2016 2:56 Assunto: Re: [xwiki-users] hql query returning objects? On Tue, Jul 12, 2016 at 7:03 PM, dullfig <dan.u@grmcompany.com> 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 users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
participants (4)
-
Daniel Ullfig -
dullfig -
Julio Brum -
Thomas Mortagne