/** * Returns the join of the given sources. * * @param factory factory for creating the join * @param left left join source * @param right right join source * @param condition join condition * @return join * @throws RepositoryException if the join can not be created */ public Join join( QueryObjectModelFactory factory, Source left, Source right, JoinCondition condition) throws RepositoryException { return factory.join(left, right, name, condition); }
/** * Returns the join of the given sources. * * @param factory factory for creating the join * @param left left join source * @param right right join source * @param condition join condition * @return join * @throws RepositoryException if the join can not be created */ public Join join( QueryObjectModelFactory factory, Source left, Source right, JoinCondition condition) throws RepositoryException { return factory.join(left, right, name, condition); }
/** * Returns the join of the given sources. * * @param factory factory for creating the join * @param left left join source * @param right right join source * @param condition join condition * @return join * @throws RepositoryException if the join can not be created */ public Join join( QueryObjectModelFactory factory, Source left, Source right, JoinCondition condition) throws RepositoryException { return factory.join(left, right, name, condition); }
/** * Returns the join of the given sources. * * @param factory factory for creating the join * @param left left join source * @param right right join source * @param condition join condition * @return join * @throws RepositoryException if the join can not be created */ public Join join( QueryObjectModelFactory factory, Source left, Source right, JoinCondition condition) throws RepositoryException { return factory.join(left, right, name, condition); }
/** * Returns the join of the given sources. * * @param factory factory for creating the join * @param left left join source * @param right right join source * @param condition join condition * @return join * @throws RepositoryException if the join can not be created */ public Join join( QueryObjectModelFactory factory, Source left, Source right, JoinCondition condition) throws RepositoryException { return factory.join(left, right, name, condition); }
/** * Returns the join of the given sources. * * @param factory factory for creating the join * @param left left join source * @param right right join source * @param condition join condition * @return join * @throws RepositoryException if the join can not be created */ public Join join( QueryObjectModelFactory factory, Source left, Source right, JoinCondition condition) throws RepositoryException { return factory.join(left, right, name, condition); }
/** * Test case for {@link QueryObjectModelFactory#join(Source, Source, String, JoinCondition)} */ public void testJoin() throws RepositoryException { Selector s1 = qf.selector(ntBase, SELECTOR_NAME1); Selector s2 = qf.selector(testNodeType, SELECTOR_NAME1); JoinCondition cond = qf.equiJoinCondition(ntBase, jcrPrimaryType, testNodeType, jcrPrimaryType); for (Iterator<String> it = JOIN_TYPES.iterator(); it.hasNext(); ) { String joinType = it.next(); Join join = qf.join(s1, s2, joinType, cond); assertTrue("Not a selector source", join.getLeft() instanceof Selector); assertTrue("Not a selector source", join.getRight() instanceof Selector); assertEquals("Wrong join type", joinType, join.getJoinType()); assertTrue("Not an EquiJoinCondition", join.getJoinCondition() instanceof EquiJoinCondition); } }
public void testLeftOuterJoin() throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.join( qf.selector(testNodeType, LEFT), qf.selector(mixReferenceable, RIGHT), QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, qf.sameNodeJoinCondition(LEFT, RIGHT, ".")), qf.descendantNode(LEFT, testRoot), null, null); checkQOM(qom, new Node[][]{{n1, null}, {n2, n2}}); }
public void testRightOuterJoin() throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.join( qf.selector(mixReferenceable, LEFT), qf.selector(testNodeType, RIGHT), QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER, qf.sameNodeJoinCondition(LEFT, RIGHT, ".")), qf.descendantNode(RIGHT, testRoot), null, null); checkQOM(qom, new Node[][]{{null, n1}, {n2, n2}}); }
public void testRightOuterJoinWithPath() throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.join( qf.selector(mixReferenceable, LEFT), qf.selector(testNodeType, RIGHT), QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER, qf.sameNodeJoinCondition(LEFT, RIGHT, nodeName2)), qf.descendantNode(RIGHT, testRoot), null, null); checkQOM(qom, new Node[][]{{n2, n1}, {null, n2}}); }
final String columnName2 = SELECTOR_2 + "." + propertyName1; QueryObjectModel qom = qf.createQuery( qf.join( qf.selector(testNodeType, SELECTOR_1), qf.selector(testNodeType, SELECTOR_2),
"{} SQL2 RIGHT OUTER JOIN transformed to LEFT OUTER JOIN.", genString(printIndentation)); Join betterJoin = qomFactory.join(join.getRight(), join.getLeft(), JCR_JOIN_TYPE_LEFT_OUTER, join.getJoinCondition()); return execute(columns, betterJoin, constraint, orderings, offset,
"{} SQL2 RIGHT OUTER JOIN transformed to LEFT OUTER JOIN.", genString(printIndentation)); Join betterJoin = qomFactory.join(join.getRight(), join.getLeft(), JCR_JOIN_TYPE_LEFT_OUTER, join.getJoinCondition()); return execute(columns, betterJoin, constraint, orderings, offset,
protected QueryObjectModel createQuery(String joinType, JoinCondition condition, Constraint left, Constraint right) throws RepositoryException { // only consider nodes under test root Constraint constraint; if (QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER.equals(joinType)) { constraint = qf.descendantNode(LEFT, testRoot); } else { constraint = qf.descendantNode(RIGHT, testRoot); } if (left != null) { constraint = qf.and(constraint, left); } if (right != null) { constraint = qf.and(constraint, right); } Join join = qf.join( qf.selector(testNodeType, LEFT), qf.selector(testNodeType, RIGHT), joinType, condition); return qf.createQuery(join, constraint, null, null); } }
public void testDuplicateNodeType() throws RepositoryException { try { Query q = qf.createQuery( qf.join( qf.selector(testNodeType, "nt"), qf.selector(testNodeType, "nt"), QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, qf.descendantNodeJoinCondition("nt", "nt")), null, null, null); q.execute(); fail("Selector with two identical selector names must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } try { String stmt = "SELECT * FROM [" + testNodeType + "] AS nt, [" + testNodeType + "] AS nt nt INNER JOIN nt ON ISDESCENDANTNODE(nt, nt)"; qm.createQuery(stmt, Query.JCR_SQL2).execute(); fail("selectorName with syntactically invalid name must throw InvalidQueryException"); } catch (InvalidQueryException e) { // expected } } }
@Test public void join() throws RepositoryException { Source left = f.selector("nodeTypeName", "selectorName"); Source right = f.selector("nodeTypeName2", "selectorName2"); ChildNodeJoinCondition jc = f.childNodeJoinCondition("childSelectorName", "parentSelectorName"); Join j = f.join(left, right, QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, jc); assertEquals(left, j.getLeft()); assertEquals(right, j.getRight()); assertEquals(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, j.getJoinType()); assertEquals(jc, j.getJoinCondition()); assertEquals("ISCHILDNODE([childSelectorName], [parentSelectorName])", jc.toString()); }