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.

 

  (cachavez)

Number of messages  32
Registration date
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.

  (cachavez)

Number of messages  32
Registration date
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