@Test
  public void testSelectWithJoinsDepthAndBreadthWithLock() {
    Visitor queryVis = getVisitor();

    Table tab1 = new Table("table1");
    Column col1 = new Column(tab1, "col1");

    Table tab2 = new Table("table2");
    Column col2 = new Column(tab2, "col2");

    Table tab3 = new Table("table3");
    Column col3 = new Column(tab3, "col3");

    Table tab4 = new Table("table4");
    Column col4 = new Column(tab4, "col4");

    Table tab5 = new Table("table5");
    Column col5 = new Column(tab5, "col5");

    Table tab6 = new Table("table6");
    Column col6 = new Column(tab6, "col6");

    Table tab7 = new Table("table7");
    Column col7 = new Column(tab7, "col7");

    Select select = new Select(tab1);
    select.setLocked(true);

    tab1.addInnerJoin(tab2, col1.equal(col2));
    tab2.addFullJoin(tab3, col2.equal(col3));
    tab2.addLeftJoin(tab7, col2.equal(col7));

    tab1.addInnerJoin(tab4, col1.equal(col4));
    tab4.addRightJoin(tab5, col4.equal(col5));
    tab5.addLeftJoin(tab6, col5.equal(col6));

    queryVis.visit(select);

    assertEquals(
        "SELECT * FROM "
            + "((\"table1\" HOLDLOCK INNER JOIN "
            + "((\"table2\" HOLDLOCK FULL JOIN \"table3\" HOLDLOCK ON "
            + "\"table2\".\"col2\"=\"table3\".\"col3\") "
            + "LEFT JOIN \"table7\" HOLDLOCK ON \"table2\".\"col2\"=\"table7\".\"col7\") "
            + "ON \"table1\".\"col1\"=\"table2\".\"col2\") "
            + "INNER JOIN (\"table4\" HOLDLOCK "
            + "RIGHT JOIN (\"table5\" HOLDLOCK LEFT JOIN \"table6\" HOLDLOCK "
            + "ON \"table5\".\"col5\"=\"table6\".\"col6\") "
            + "ON \"table4\".\"col4\"=\"table5\".\"col5\") "
            + "ON \"table1\".\"col1\"=\"table4\".\"col4\")",
        queryVis.toString());
  }
  @Test
  public void testSelectWithFromAndJoinsWithLock() {
    Visitor queryVis = getVisitor();

    Table tab1 = new Table("FOO");
    Column col1 = new Column(tab1, "ID");

    Table tab2 = new Table("BAR");
    Column col21 = new Column(tab2, "ID");
    Column col22 = new Column(tab2, "ABC_ID");

    TableAlias tab3 = new TableAlias(new Table("ABC"), "xyz");
    Column col3 = new Column(tab3, "ID");

    Table tab4 = new Table("FN");
    Table tab5 = new Table("ORD");
    TableAlias tab6 = new TableAlias(new Table("FN"), "abc");

    Select sel = new Select(tab1);
    sel.setLocked(true);
    tab1.addInnerJoin(tab2, col1.equal(col21));
    tab2.addLeftJoin(tab3, col22.equal(col3));

    sel.addFrom(tab4);
    sel.addFrom(tab5);
    tab5.addRightJoin(tab6);

    queryVis.visit(sel);

    assertTrue(sel.hasFrom());

    Iterator<Qualifier> iter = sel.getFrom().iterator();
    assertEquals(iter.next(), tab1);
    assertEquals(iter.next(), tab4);
    assertEquals(iter.next(), tab5);
    assertFalse(iter.hasNext());

    assertEquals(
        "SELECT * "
            + "FROM (\"FOO\" HOLDLOCK "
            + "INNER JOIN (\"BAR\" HOLDLOCK "
            + "LEFT JOIN \"ABC\" \"xyz\" HOLDLOCK "
            + "ON \"BAR\".\"ABC_ID\"=\"xyz\".\"ID\") "
            + "ON \"FOO\".\"ID\"=\"BAR\".\"ID\")"
            + ", \"FN\" HOLDLOCK, (\"ORD\" HOLDLOCK RIGHT JOIN \"FN\" \"abc\" "
            + "HOLDLOCK)",
        queryVis.toString());
  }
  @Test
  public void testSelectWithJoinsDepthWithLock() {
    Visitor queryVis = getVisitor();

    Table tab1 = new Table("FOO");
    Column col1 = new Column(tab1, "ID");

    Table tab2 = new Table("BAR");
    Column col21 = new Column(tab2, "ID");
    Column col22 = new Column(tab2, "ABC_ID");

    TableAlias tab3 = new TableAlias(new Table("ABC"), "xyz");
    Column col3 = new Column(tab3, "ID");

    Select sel = new Select(tab1);
    sel.setLocked(true);
    queryVis.visit(sel);
    assertEquals("SELECT * FROM \"FOO\" HOLDLOCK", queryVis.toString());

    queryVis = getVisitor();
    tab1.addInnerJoin(tab2, col1.equal(col21));
    queryVis.visit(sel);
    assertEquals(
        "SELECT * "
            + "FROM (\"FOO\" HOLDLOCK "
            + "INNER JOIN \"BAR\" HOLDLOCK "
            + "ON \"FOO\".\"ID\"=\"BAR\".\"ID\")",
        queryVis.toString());

    queryVis = getVisitor();
    tab2.addLeftJoin(tab3, col22.equal(col3));
    queryVis.visit(sel);
    assertEquals(
        "SELECT * "
            + "FROM (\"FOO\" HOLDLOCK "
            + "INNER JOIN (\"BAR\" HOLDLOCK "
            + "LEFT JOIN \"ABC\" \"xyz\" HOLDLOCK "
            + "ON \"BAR\".\"ABC_ID\"=\"xyz\".\"ID\") "
            + "ON \"FOO\".\"ID\"=\"BAR\".\"ID\")",
        queryVis.toString());
  }