RE: [xwiki-users] HQL Queries - multiple objects
Hi Jérémi, Not quite - the problem I'm having seems to stem from getDocument usage to collect objects. I've done a bit of testing I guess to illustrate, here is a snippet of the code I currently use (where the problem seems to be at least): ____________ #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.SampleBookTest001Class' and obj.name<>'XWiki.SampleBookTest001ClassTemplate' order by obj.name asc") #foreach ($item in $xwiki.searchDocuments($sql)) #set($oDocObject= $xwiki.getDocument($item)) #set($bentryobj = $oDocObject.getObject("XWiki.SampleBookTest001Class")) #set($initialReqDate = $oDocObject.display("dtInitialReq","view", $bentryobj)) <tr title="Initial Request Date: ${initialReqDate}"> <td valign="top" width="30%"> [$oDocObject.display("SampleReference","view", $bentryobj)>$oDocObject.name] </td> <td colspan="2" width="50%"> <table border-left="1" width="98%"> #set($objects= $oDocObject.getObjects("XWiki.SamplePartEntryClass")) #foreach($object in $objects) <tr> <td width="50%">$oDocObject.display("PartNum","rendered",$object)</td> <td width="50%">$oDocObject.display("DeliveryRequest","rendered",$object)</td> </tr> #end </table> </td> <td valign="top" width="20%">$oDocObject.display("MVSEngineer","view", $bentryobj)</td> </tr> #end ____________ What I'm finding is that the $xwiki.getDocument() call is making the time-to-run for these details extremely long (removing the getDocument makes this call exremely fast for 130 documents, whereas normally it takes up to and over two minutes, keeping tomcat at 50% during the collection). You can imagine what happens when more than one person gets a listing (tried convincing powers-that-be about pagination, not an option they're willing to allow for this). My thinking (maybe incorrect) was, remove the getDocument() call and replace with a plain data query, so that I don't need to gather the actual document object - though maybe that's the wrong way round? -----Original Message----- From: jeremi joslin [mailto:[email protected]] Sent: 21 April 2006 02:36 To: [email protected] Subject: Re: [xwiki-users] HQL Queries - multiple objects Hi, i'm not sure if it's what you want. the code below search every page which contains a class "XWiki.CandidatClass" except the page "XWiki.CandidatClassTemplate" and have a property status=$status. #macro (showCandidat $status) #set ($sql = ", BaseObject as obj, StringProperty as prop where obj.name=doc.fullName and obj.className='XWiki.CandidatClass' and obj.name<>'XWiki.CandidatClassTemplate' and obj.id=prop.id.id and prop.id.name='status' and prop.value='$status' order by prop.value desc") #foreach ($item in $xwiki.searchDocuments($sql)) #set($bentrydoc = $xwiki.getDocument($item)) #set($bentryobj = $bentrydoc.getObject("XWiki.CandidatClass")) 1.1.1 [$bentrydoc.display("name","view", $bentryobj)>$bentrydoc.FullName] #end #end Is it what you mean? Jérémi On 4/20/06, Esbach, Brandon <[email protected]> wrote:
Hi all,
I was wondering, is it possible to use a single query to get document details and specified linked objects using one query (specific fields of those objects would be even better)?
For example, A document is created using a class template. Inside the document are used two other classes, which are used multiple times.
One of those classes is used for critical information that needs to be shown in the document listing. Currently what I do is to return a query based on the class for documents, then loop through those results for document names. Inside each loop I'm performing a second loop for the class with critical information (shown in the listing). This eventually results in some fairly heavy traffic (as you could imagine), which I'd like to resolve.
Not sure if this description is clear enough, but any suggestions or idea's would be welcome!
Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
-- 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
-- Blog: http://www.jeremi.info LinkedIn: https://www.linkedin.com/profile?viewProfile=&key=1437724 Project Manager XWiki: http://www.xwiki.org skype: jeremi23 -- msn et gtalk : [email protected]
On 4/21/06, Esbach, Brandon <[email protected]> wrote:
Hi Jérémi,
Not quite - the problem I'm having seems to stem from getDocument usage to collect objects. I've done a bit of testing I guess to illustrate, here is a snippet of the code I currently use (where the problem seems to be at least):
____________
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.SampleBookTest001Class' and obj.name<>'XWiki.SampleBookTest001ClassTemplate' order by obj.name asc") #foreach ($item in $xwiki.searchDocuments($sql)) #set($oDocObject= $xwiki.getDocument($item)) #set($bentryobj = $oDocObject.getObject("XWiki.SampleBookTest001Class")) #set($initialReqDate = $oDocObject.display("dtInitialReq","view", $bentryobj)) <tr title="Initial Request Date: ${initialReqDate}"> <td valign="top" width="30%"> [$oDocObject.display("SampleReference","view", $bentryobj)>$oDocObject.name] </td> <td colspan="2" width="50%"> <table border-left="1" width="98%"> #set($objects= $oDocObject.getObjects("XWiki.SamplePartEntryClass")) #foreach($object in $objects) <tr> <td width="50%">$oDocObject.display("PartNum","rendered",$object)</td> <td width="50%">$oDocObject.display("DeliveryRequest","rendered",$object)</td> </tr> #end </table> </td> <td valign="top" width="20%">$oDocObject.display("MVSEngineer","view", $bentryobj)</td> </tr> #end ____________
What I'm finding is that the $xwiki.getDocument() call is making the time-to-run for these details extremely long (removing the getDocument makes this call exremely fast for 130 documents, whereas normally it takes up to and over two minutes, keeping tomcat at 50% during the collection). You can imagine what happens when more than one person gets a listing (tried convincing powers-that-be about pagination, not an option they're willing to allow for this). My thinking (maybe incorrect) was, remove the getDocument() call and replace with a plain data query, so that I don't need to gather the actual document object - though maybe that's the wrong way round?
Look at the function $xwiki.search() which allow you to execute hsql query without loading the document. Like this you can load the datas directly. Jérémi -- Blog: http://www.jeremi.info LinkedIn: https://www.linkedin.com/profile?viewProfile=&key=1437724 Project Manager XWiki: http://www.xwiki.org skype: jeremi23 -- msn et gtalk : [email protected]
participants (2)
-
Esbach, Brandon -
jeremi joslin