use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class SelectClauseTest method testSameNameSiblingSQL.
public void testSameNameSiblingSQL() throws RepositoryException {
Node n = testRootNode.addNode("node");
n.setProperty("myvalue", "foo");
n = testRootNode.addNode("node");
n.setProperty("myvalue", "bar");
n = testRootNode.addNode("node");
n.setProperty("yourvalue", "foo");
testRootNode.save();
String sql = "SELECT myvalue FROM " + ntBase + " WHERE " + "jcr:path LIKE '" + testRoot + "/node[%]' AND myvalue IS NOT NULL";
Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
QueryResult result = q.execute();
checkResult(result, 2, 2);
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class SQL2OrderByTest method testOrderByVal.
public void testOrderByVal() throws RepositoryException {
Node n1 = testRootNode.addNode("node1");
Node n2 = testRootNode.addNode("node2");
Node n3 = testRootNode.addNode("node3");
n1.setProperty("value", 3);
n2.setProperty("value", 1);
n3.setProperty("value", 2);
testRootNode.getSession().save();
QueryResult qr = executeSQL2Query("SELECT * FROM [nt:base] WHERE ISCHILDNODE([" + testRoot + "]) ORDER BY [value]");
checkSeq(qr, new Node[] { n2, n3, n1 });
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class SQL2OrderByTest method testOrderByValMultMix.
public void testOrderByValMultMix() throws RepositoryException {
Node n1 = testRootNode.addNode("node1");
Node n2 = testRootNode.addNode("node2");
Node n3 = testRootNode.addNode("node3");
n1.setProperty("value", 2);
n1.setProperty("text", "b");
n2.setProperty("value", 1);
n2.setProperty("text", "x");
n3.setProperty("value", 2);
n3.setProperty("text", "a");
testRootNode.getSession().save();
QueryResult qr = executeSQL2Query("SELECT * FROM [nt:base] WHERE ISCHILDNODE([" + testRoot + "]) ORDER BY [value], [text] desc");
checkSeq(qr, new Node[] { n2, n1, n3 });
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class SQL2OrderByTest method testOrderByValMultDesc.
public void testOrderByValMultDesc() throws RepositoryException {
Node n1 = testRootNode.addNode("node1");
Node n2 = testRootNode.addNode("node2");
Node n3 = testRootNode.addNode("node3");
n1.setProperty("value", 2);
n1.setProperty("text", "b");
n2.setProperty("value", 1);
n2.setProperty("text", "x");
n3.setProperty("value", 2);
n3.setProperty("text", "a");
testRootNode.getSession().save();
QueryResult qr = executeSQL2Query("SELECT * FROM [nt:base] WHERE ISCHILDNODE([" + testRoot + "]) ORDER BY [value] desc, [text] desc");
checkSeq(qr, new Node[] { n1, n3, n2 });
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class SQL2OrderByTest method testOrderByScore.
public void testOrderByScore() throws RepositoryException {
Node n1 = testRootNode.addNode("node1");
Node n2 = testRootNode.addNode("node2");
Node n3 = testRootNode.addNode("node3");
n1.setProperty("text", "aaa");
n1.setProperty("value", 3);
testRootNode.getSession().save();
n2.setProperty("text", "bbb");
n2.setProperty("value", 2);
testRootNode.getSession().save();
n3.setProperty("text", "ccc");
n3.setProperty("value", 2);
testRootNode.getSession().save();
QueryResult qr = executeSQL2Query("SELECT * FROM [nt:base] WHERE ISCHILDNODE([" + testRoot + "]) ORDER BY SCORE()");
RowIterator rows = qr.getRows();
long size = rows.getSize();
assertTrue(size == 3 || size == -1);
size = 0;
double score = Double.MIN_VALUE;
while (rows.hasNext()) {
double nextScore = rows.nextRow().getScore();
assertTrue(nextScore >= score);
score = nextScore;
size++;
}
assertEquals(3, size);
}
Aggregations