protected boolean inRecursiveRelation(TableNode tableNode) { RelationNode relNode = (RelationNode) tableNode.getParent(); if (relNode == null) return false; return relNode.getRelation().isBinaryRecursive(); }
/* * Determines whether we reached the current relation node through a lazy relation in the past */ private boolean traversedLazyRelation(Fetching currFetching, RelationNode relationNode) { TableNode parentTableNode = relationNode.getParentTable(); RelationNode parentRelNode = (RelationNode) parentTableNode.getParent(); if (parentRelNode == null) // in case the parent table was the base table return false; boolean parentRelIsLazy = parentRelNode.getTableRelation().getFetching().equals(Fetching.LAZY); if (startedALazySelect(parentRelNode)) return false; boolean traversedLazyRel = parentRelIsLazy || parentRelNode.isMarkedAsLazy(); // Can not traverse an eager relation after traversing a Lazy one except in a lazy Select. return currFetching != null && currFetching.equals(Fetching.EAGER) && traversedLazyRel; }
/* * In need some cases, we need to transform the fecthing of a relation for overcoming the problem of traversing lazy relations * If we encounter an eager relation after traversing lazy relations, we transform the eager relation pretends to be a lazy one * so its columns are not traversed */ private Fetching getFetchingForRelationNode(RelationNode relationNode) { Fetching fetch = relationNode.getTableRelation().getFetching(); if (fetch.equals(Fetching.EAGER)) { TableNode parentTableNode = relationNode.getParentTable(); RelationNode parentRelNode = (RelationNode) parentTableNode.getParent(); if (parentRelNode == null) return fetch; if (startedALazySelect(parentRelNode)) return fetch; if (parentRelNode.getTableRelation().getFetching().equals(Fetching.LAZY)) { relationNode.setMarkedAsLazy(true); return Fetching.LAZY; } } return fetch; }
/* * Determines whether we just initated a lazy select by checking if there is no * other relation at the upper level of the current one */ private boolean startedALazySelect(RelationNode relNode) { TableNode parentTable = relNode.getParentTable(); boolean res = parentTable.getParent() == null && ctx.isInLazyQuery(); return res; }