Jahia in English > SQL weakreference

0 (0 Good)
0 (0 Bad)

SQL weakreference

by  cachavez »  2011/12/01 08:55

Hi all.

I was trying to use a jcr:sql

I have the following structures:

 

[jnt:parent] > ....

 

[jnt:child] > .....

   - parent (weakreference) < [jnt:parent]

 

What I want to do, is create a query that retrieves the child based on the parent properties.

someting like:

select * from [jnt:child] as p where p.parent = '${currentNodel}' order by p.[jcr:lastModified] desc"

something like that.

the main thing is retrieves the child for a specific parent property.

--

Cheers.

Carlos Chávez.

Quoin Inc.

 

  • SQL weakreference
    2011/12/01 08:55

    cachavez <p> Hi all.</p> <p> I was trying to use a jcr:sql</p> <p> I have the following structures:</p> <p> &nbsp;</p> <p> [jnt:parent] &gt; ....</p> <p> &nbsp;</p> <p> [jnt:child] &gt; .....</p> <p> &nbsp;&nbsp; - parent (weakreference) &lt; [jnt:parent]</p> <p> &nbsp;</p> <p> What I want to do, is create a query that retrieves the child based on the parent properties.</p> <p> someting like:</p> <p> select * from [jnt:child] as p where p.parent = &#39;${currentNodel}&#39; order by p.[jcr:lastModified] desc&quot;</p> <p> something like that.</p> <p> the main thing is retrieves the child for a specific parent property.</p> <p> --</p> <p> Cheers.</p> <p> Carlos Ch&aacute;vez.</p> <p> Quoin Inc.</p> <p> &nbsp;</p>

  • Number of messages  32
    Registration date Dec 1, 2011
    0 (0 Good)
    0 (0 Bad)

    Re: SQL weakreference

    by  pap@commaro.com »  2011/12/01 09:27

    Hello Carlos,

    I guess you can do it with a join:

    select * from [jnt:child] as child inner join [jnt:parent] as parent on child.[parent] = parent.[jcr:uuid] where parent.[<some-property>] = <some-value>

    Regards,

    Benjamin

    Benjamin Papez (pap@commaro.com)

    Number of messages  220
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: Re: SQL weakreference

    by  cachavez »  2011/12/01 09:45

    Hello Benjamin.

    thanks for the reply, it help a lot. I did not do with joins, but the following "child.[parent] = parent.[jcr:uuid]" in your sql got me an idea :)

    I finally did in the following way:

    select * from [jnt:child] as p where p.parent = '${currentNode.properties['jcr:uuid'].string}'

    It look like in the weakreference parent it store the uuid of the node.

    --

    Cheers.

    Carlos Chávez.

    Quoin Inc.

  • Re: Re: SQL weakreference
    2011/12/01 09:45

    cachavez <p> Hello Benjamin.</p> <p> thanks for the reply, it help a lot. I did not do with joins, but the following &quot;child.[parent] = parent.[jcr:uuid]&quot; in your sql got me an idea :)</p> <p> I finally did in the following way:</p> <p> select * from [jnt:child] as p where p.parent = &#39;${currentNode.properties[&#39;jcr:uuid&#39;].string}&#39;</p> <p> It look like in the weakreference parent it store the uuid of the node.</p> <p> --</p> <p> Cheers.</p> <p> Carlos Ch&aacute;vez.</p> <p> Quoin Inc.</p>

  • Number of messages  32
    Registration date Dec 1, 2011
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: SQL weakreference

    by  pap@commaro.com »  2011/12/01 09:57

    Hello Carlos,

    yes its fine.

    I misunderstood your request about "query that retrieves the child based on the parent properties" as I thought that you want to include some properties of the jnt:parent node, thats why I suggested a join. Now I see that by parent properties you just meant the parent property of the jnt:child node.

    Regards,

    Benjamin

    Benjamin Papez (pap@commaro.com)

    Number of messages  220
    Registration date
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page