Package javax.jcr.query

Examples of javax.jcr.query.QueryManager.createQuery()


            assertTrue(e.toString(), e.toString().indexOf(
                    "literals of this type not allowed") > 0);
        }

        // secure
        Query q = qm.createQuery(
                "select text from [nt:base] where password = $p",
                Query.JCR_SQL2 + "-noLiterals");
        q.bindValue("p", vf.createValue("x"));
        q.execute();
    }
View Full Code Here


            session.save();

            ValueFactory vf = session.getValueFactory();

            QueryManager qm = session.getWorkspace().getQueryManager();
            Query q = qm.createQuery("select text from [nt:base] where id = $id", Query.JCR_SQL2);
            q.bindValue("id", vf.createValue("1"));
            QueryResult r = q.execute();
            RowIterator it = r.getRows();
            assertTrue(it.hasNext());
            Row row = it.nextRow();
View Full Code Here

        Node n2 = testRootNode.addNode("node2");
        n2.setProperty("text", "hello");
        session.save();

        String xpath = "/jcr:root//*[jcr:contains(@text, 'hello')] order by jcr:score()";
        Query q = qm.createQuery(xpath, "xpath");
        String result = getResult(q.execute(), "jcr:score");
        // expect two numbers (any value)
        result = result.replaceAll("[0-9\\.]+", "n");
        assertEquals("n, n", result);
    }
View Full Code Here

        session.save();

        // lowercase "or" mean search for the term "or"
        String sql2 = "select [jcr:path] as [path] from [nt:base] " +
                "where contains([text], 'hello or hallo') order by [jcr:path]";
        Query q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("", getResult(q.execute(), "path"));

    }

    public void testFulltextRelativeProperty() throws Exception {
View Full Code Here

        String sql2 = "select [jcr:path] as [path] from [nt:base] " +
                "where ISCHILDNODE([/testroot])" +
                " AND CONTAINS(text, 'hallo')";

        q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("/testroot/node2, /testroot/node3", getResult(q.execute(), "path"));
//
//        sql2 = "select [jcr:path] as [path] from [nt:base] "
//                + "where contains([node1/text], 'hello') order by [jcr:path]";
//        q = qm.createQuery(sql2, Query.JCR_SQL2);
View Full Code Here

        Node n2 = testRootNode.addNode("node2");
        n2.setProperty("text", "hello");
        session.save();

        String xpath = "/jcr:root//*[jcr:contains(@text, 'hello')] order by jcr:score()";
        Query q = qm.createQuery(xpath, "xpath");
        String result = getResult(q.execute(), "jcr:score");
        // expect two numbers (any value)
        result = result.replaceAll("[0-9\\.]+", "n");
        assertEquals("n, n", result);
    }
View Full Code Here

        session.save();

        // lowercase "or" mean search for the term "or"
        String sql2 = "select [jcr:path] as [path] from [nt:base] " +
                "where contains([text], 'hello or hallo') order by [jcr:path]";
        Query q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("", getResult(q.execute(), "path"));

    }

    public void testFulltextRelativeProperty() throws Exception {
View Full Code Here

        String sql2 = "select [jcr:path] as [path] from [nt:base] " +
                "where ISCHILDNODE([/testroot])" +
                " AND CONTAINS(text, 'hallo')";

        q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("/testroot/node2, /testroot/node3", getResult(q.execute(), "path"));

        sql2 = "select [jcr:path] as [path] from [nt:base] "
                + "where contains([node1/text], 'hello') order by [jcr:path]";
        q = qm.createQuery(sql2, Query.JCR_SQL2);
View Full Code Here

        q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("/testroot/node2, /testroot/node3", getResult(q.execute(), "path"));

        sql2 = "select [jcr:path] as [path] from [nt:base] "
                + "where contains([node1/text], 'hello') order by [jcr:path]";
        q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("/testroot", getResult(q.execute(), "path"));

        sql2 = "select [jcr:path] as [path] from [nt:base] "
                + "where contains([node2/text], 'hello OR hallo') order by [jcr:path]";
        q = qm.createQuery(sql2, Query.JCR_SQL2);
View Full Code Here

        q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("/testroot", getResult(q.execute(), "path"));

        sql2 = "select [jcr:path] as [path] from [nt:base] "
                + "where contains([node2/text], 'hello OR hallo') order by [jcr:path]";
        q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("/testroot", getResult(q.execute(), "path"));

        // TODO OAK-890
        // sql2 = "select [jcr:path] as [path] from [nt:base] "
        // + "where contains([node1/text], 'hello') "
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.