On Sep 28, 2011, at 09:58 , Jukka Zitting wrote:

> Hi,
> 
> On Wed, Sep 28, 2011 at 12:27 AM, Lukas Kahwe Smith <[email protected]> 
> wrote:
>> speaking of JOIN, i ran into this issue before but getting a 403 Repository 
>> exception when I send a simple JOIN via davex:
>> 
>> <D:searchrequest xmlns:D="DAV:"><JCR-SQL2><![CDATA[SELECT * FROM 
>> [nt:unstructured] AS data INNER JOIN [nt:unstructured] AS referring ON 
>> referring.reference = data.[jcr:uuid] WHERE data.foo = 
>> 'bar']]></JCR-SQL2></D:searchrequest>
>> 
>> so far the only JOIN's I have managed to send without an error are those 
>> that have zero results ..
> 
> I wonder if that's a problem with the remoting layer having trouble
> dealing with results that contain more than a single selector. Does
> specifying SELECT data.* instead of just SELECT * help?


that doesnt seem to be it either ..

here is the code i am using. note its using PHPCR to setup the nodes (which 
means the next step will be doing all of the below via Java)

$session = $this->getContainer()->get('phpcr.session');
$rootNode = $session->getRootNode();

// /foo [nt:unstructured]
$fooNode = $rootNode->addNode('foo', 'nt:unstructured');

// /foo/bar [nt:unstructured]
$barNode = $fooNode->addNode('bar', 'nt:unstructured');
$barNode->addMixin("mix:referenceable");

// /foo/bar@lala = huii (lala is string property of bar)
$barNode->setProperty('lala', 'huii', \PHPCR\PropertyType::STRING);

// /ding [nt:unstructured]
$dingNode = $rootNode->addNode('ding', 'nt:unstructured');

$session->save();

// /ding@dong = ##barUUID### (dong is a property of type "Reference")
$dingNode->setProperty('dong', $barNode, \PHPCR\PropertyType::REFERENCE);

$session->save();

$qm = $session->getWorkspace()->getQueryManager();

$statement = "SELECT data.* FROM [nt:unstructured] AS data WHERE data.lala= 
'huii'";
$query = $qm->createQuery($statement, \PHPCR\Query\QueryInterface::JCR_SQL2);

// this executes fine and the row is outputted properly
$nodes = $query->execute();
foreach ($nodes->getRows() as $row) {
    var_dump($row->getValues());
}

$statement = "SELECT data.* FROM [nt:unstructured] AS data INNER JOIN 
[nt:unstructured] AS referring ON referring.[dong] = data.[jcr:uuid] WHERE 
data.lala= 'huii'";
$query = $qm->createQuery($statement, \PHPCR\Query\QueryInterface::JCR_SQL2);

// the following line throws an exception unless I skip setting the reference
$nodes = $query->execute();
foreach ($nodes->getRows() as $row) {
    var_dump($row->getValues());
}

The second query is send as the following:
<D:searchrequest xmlns:D="DAV:"><JCR-SQL2><![CDATA[SELECT data.* FROM 
[nt:unstructured] AS data INNER JOIN [nt:unstructured] AS referring ON 
referring.[dong] = data.[jcr:uuid] WHERE data.lala= 
'huii']]></JCR-SQL2></D:searchrequest>

And this is the response I am receiving:
<?xml version="1.0" encoding="UTF-8"?><D:error xmlns:D="DAV:"><dcr:exception 
xmlns:dcr="http://www.day.com/jcr/webdav/1.0";><dcr:class>javax.jcr.RepositoryException</dcr:class><dcr:message/></dcr:exception></D:error>"

regards,
Lukas Kahwe Smith
[email protected]



Reply via email to