I have a domain object that has a parent child relationship. I am setting up a query that returns objects that don't have any children (recursively) that satisfy a particular condition. The code below is not exactly what I am doing, but it is close enough to illustrate my issue:
ExpressionBuilder parentBuilder = new ExpressionBuilder();
ExpressionBuilder childBuilder = new ExpressionBuilder();
ReportQuery subQuery = new ReportQuery(DomainObject.class, childBuilder);
Expression startWith = childBuilder.equal(parentBuilder.get("parent"));
Expression connectBy = childBuilder.get("children");
subQuery.setHierarchicalQueryClause(startWith, connectBy, null);
subQuery.addAttribute("oid");
return parentBuilder.notExists(subQuery);
As you can see, I am using two separate expression builders to set up the correlated subquery. I expect the generated sql to look something like:
SELECT t0.* FROM DOMAIN_OBJECT t0 WHERE NOT EXISTS (SELECT t1.OID FROM DOMAIN_OBJECT t1 START WITH t1.OID = t0.PARENT_OID CONNECT BY t1.PARENT_OID = PRIOR t1.OID);
However, the generated sql ends up using the wrong alias (t1) in the start with clause:
SELECT t0.* FROM DOMAIN_OBJECT t0 WHERE NOT EXISTS (SELECT t1.OID FROM DOMAIN_OBJECT t1 START WITH t1.OID = t1.PARENT_OID CONNECT BY t1.PARENT_OID = PRIOR t1.OID);
I assume this is a bug, but I'm not sure if I am doing something incorrectly. Has anyone seen anything like this? Any known work arounds?
Thanks!
Will