added cte set operation builder test case
@@ -678,6 +678,34 @@ public class CTETest extends AbstractCoreTest {
cb.getResultList();
}
+ @Test
+ @Category({ NoDatanucleus.class, NoEclipselink.class, NoOpenJPA.class, NoMySQL.class })
+ public void testWithStartSetEmptyLeftSideLeaf() {
+ CriteriaBuilder<TestCTE> cb = cbf.create(em, TestCTE.class).withStartSet(TestCTE.class)
+ .from(RecursiveEntity.class, "e")
+ .bind("id").select("e.id")
+ .bind("name").select("e.name")
+ .bind("level").select("0")
+ .exceptAll()
+ .from(RecursiveEntity.class, "e")
+ .bind("id").select("e.id")
+ .bind("name").select("e.name")
+ .bind("level").select("0")
+ .endSet()
+ .startUnionAll().endSet()
+ .endSet().end();
+
+ String expected = ""
+ + "WITH " + TestCTE.class.getSimpleName() + "(id, name, level) AS(\n"
+ + "SELECT e.id, e.name, 0 FROM RecursiveEntity e\n"
+ + "EXCEPT ALL\n"
+ + "SELECT e.id, e.name, 0 FROM RecursiveEntity e\n"
+ + ")\n"
+ + "SELECT testcte FROM " + TestCTE.class.getSimpleName() + " testcte";
+ assertEquals(expected, cb.getQueryString());
+ cb.getResultList();
+ }
+
@Test
@Category({ NoDatanucleus.class, NoEclipselink.class, NoOpenJPA.class, NoMySQL.class })
public void testBuilderEndTracking() {
