/** * INTERNAL * If called this AttributeNode represents an unqualified field access. * The method returns a DotNode representing a qualified field access with * the base variable as left child node and the attribute as right child * node. */ public Node qualifyAttributeAccess(ParseTreeContext context) { return (Node)context.getNodeFactory().newQualifiedAttribute( getLine(), getColumn(), context.getBaseVariable(), name); }
/** * INTERNAL * If called this AttributeNode represents an unqualified field access. * The method returns a DotNode representing a qualified field access with * the base variable as left child node and the attribute as right child * node. */ public Node qualifyAttributeAccess(ParseTreeContext context) { return (Node)context.getNodeFactory().newQualifiedAttribute( getLine(), getColumn(), context.getBaseVariable(), name); }
/** * INTERNAL * If called this AttributeNode represents an unqualified field access. * The method returns a DotNode representing a qualified field access with * the base variable as left child node and the attribute as right child * node. */ public Node qualifyAttributeAccess(ParseTreeContext context) { return (Node)context.getNodeFactory().newQualifiedAttribute( getLine(), getColumn(), context.getBaseVariable(), name); }
/** */ private void validateNavigation(Node qualifier, ParseTreeContext context) { if (qualifier.isDotNode()) { TypeHelper typeHelper = context.getTypeHelper(); Node left = qualifier.getLeft(); AttributeNode attributeNode = (AttributeNode)qualifier.getRight(); String attribute = attributeNode.getAttributeName(); Object type = left.getType(); if (!typeHelper.isEmbeddedAttribute(type, attribute)) { throw JPQLException.invalidSetClauseNavigation( context.getQueryInfo(), attributeNode.getLine(), attributeNode.getColumn(), qualifier.getAsString(), attribute); } validateNavigation(left, context); } }
/** */ private void validateNavigation(Node qualifier, ParseTreeContext context) { if (qualifier.isDotNode()) { TypeHelper typeHelper = context.getTypeHelper(); Node left = qualifier.getLeft(); AttributeNode attributeNode = (AttributeNode)qualifier.getRight(); String attribute = attributeNode.getAttributeName(); Object type = left.getType(); if (!typeHelper.isEmbeddedAttribute(type, attribute)) { throw JPQLException.invalidSetClauseNavigation( context.getQueryInfo(), attributeNode.getLine(), attributeNode.getColumn(), qualifier.getAsString(), attribute); } validateNavigation(left, context); } }
/** */ private void validateNavigation(Node qualifier, ParseTreeContext context) { if (qualifier.isDotNode()) { TypeHelper typeHelper = context.getTypeHelper(); Node left = qualifier.getLeft(); AttributeNode attributeNode = (AttributeNode)qualifier.getRight(); String attribute = attributeNode.getAttributeName(); Object type = left.getType(); if (!typeHelper.isEmbeddedAttribute(type, attribute)) { throw JPQLException.invalidSetClauseNavigation( context.getQueryInfo(), attributeNode.getLine(), attributeNode.getColumn(), qualifier.getAsString(), attribute); } validateNavigation(left, context); } }
/** */ private void validateTarget(Node node, ParseTreeContext context) { if (node.isDotNode()) { TypeHelper typeHelper = context.getTypeHelper(); Node path = node.getLeft(); Object type = path.getType(); AttributeNode attributeNode = (AttributeNode)node.getRight(); String attribute = attributeNode.getAttributeName(); if (typeHelper.isSingleValuedRelationship(type, attribute) || typeHelper.isSimpleStateAttribute(type, attribute)) { validateNavigation(path, context); } else { throw JPQLException.invalidSetClauseTarget( context.getQueryInfo(), attributeNode.getLine(), attributeNode.getColumn(), path.getAsString(), attribute); } } }
/** */ private void validateTarget(Node node, ParseTreeContext context) { if (node.isDotNode()) { TypeHelper typeHelper = context.getTypeHelper(); Node path = node.getLeft(); Object type = path.getType(); AttributeNode attributeNode = (AttributeNode)node.getRight(); String attribute = attributeNode.getAttributeName(); if (typeHelper.isSingleValuedRelationship(type, attribute) || typeHelper.isSimpleStateAttribute(type, attribute)) { validateNavigation(path, context); } else { throw JPQLException.invalidSetClauseTarget( context.getQueryInfo(), attributeNode.getLine(), attributeNode.getColumn(), path.getAsString(), attribute); } } }
/** */ private void validateTarget(Node node, ParseTreeContext context) { if (node.isDotNode()) { TypeHelper typeHelper = context.getTypeHelper(); Node path = node.getLeft(); Object type = path.getType(); AttributeNode attributeNode = (AttributeNode)node.getRight(); String attribute = attributeNode.getAttributeName(); if (typeHelper.isSingleValuedRelationship(type, attribute) || typeHelper.isSimpleStateAttribute(type, attribute)) { validateNavigation(path, context); } else { throw JPQLException.invalidSetClauseTarget( context.getQueryInfo(), attributeNode.getLine(), attributeNode.getColumn(), path.getAsString(), attribute); } } }
/** */ public Expression addToExpression(Expression parentExpression, GenerationContext context) { if (isCollectionAttribute()) { //special case for NOT MEMBER OF if (context.hasMemberOfNode()) { return parentExpression.noneOf(name, new ExpressionBuilder().equal(context.getMemberOfNode().getLeftExpression())); } return outerJoin ? parentExpression.anyOfAllowingNone(name) : parentExpression.anyOf(name); } else { // check whether collection attribute is required if (requiresCollectionAttribute()) { throw JPQLException.invalidCollectionMemberDecl( context.getParseTreeContext().getQueryInfo(), getLine(), getColumn(), name); } if (context.shouldUseOuterJoins() || isOuterJoin()) { return parentExpression.getAllowingNull(name); } else { return parentExpression.get(name); } } }
/** */ public Expression addToExpression(Expression parentExpression, GenerationContext context) { if (isCollectionAttribute()) { //special case for NOT MEMBER OF if (context.hasMemberOfNode()) { return parentExpression.noneOf(name, new ExpressionBuilder().equal(context.getMemberOfNode().getLeftExpression())); } return outerJoin ? appendCast(parentExpression.anyOfAllowingNone(name), context) : appendCast(parentExpression.anyOf(name), context); } else { // check whether collection attribute is required if (requiresCollectionAttribute()) { throw JPQLException.invalidCollectionMemberDecl( context.getParseTreeContext().getQueryInfo(), getLine(), getColumn(), name); } if (context.shouldUseOuterJoins() || isOuterJoin()) { return appendCast(parentExpression.getAllowingNull(name), context); } else { return appendCast(parentExpression.get(name), context); } } }
/** */ public Expression addToExpression(Expression parentExpression, GenerationContext context) { if (isCollectionAttribute()) { //special case for NOT MEMBER OF if (context.hasMemberOfNode()) { return parentExpression.noneOf(name, new ExpressionBuilder().equal(context.getMemberOfNode().getLeftExpression())); } return outerJoin ? appendCast(parentExpression.anyOfAllowingNone(name), context) : appendCast(parentExpression.anyOf(name), context); } else { // check whether collection attribute is required if (requiresCollectionAttribute()) { throw JPQLException.invalidCollectionMemberDecl( context.getParseTreeContext().getQueryInfo(), getLine(), getColumn(), name); } if (context.shouldUseOuterJoins() || isOuterJoin()) { return appendCast(parentExpression.getAllowingNull(name), context); } else { return appendCast(parentExpression.get(name), context); } } }
/** * INTERNAL * Checks whether the left hand side of this dot node is navigable. */ private void checkNavigation(Node node, ParseTreeContext context) { TypeHelper typeHelper = context.getTypeHelper(); // Checks whether the type of the dot node allows a navigation. Object type = node.getType(); if (!typeHelper.isEntityClass(type) && !typeHelper.isEmbeddable(type) && !typeHelper.isEnumType(type)) { throw JPQLException.invalidNavigation( context.getQueryInfo(), node.getLine(), node.getColumn(), this.getAsString(), node.getAsString(), typeHelper.getTypeName(type)); } // Special check to disallow collection valued relationships if (node.isDotNode()) { Node left = node.getLeft(); AttributeNode right = (AttributeNode)node.getRight(); if (typeHelper.isCollectionValuedRelationship( left.getType(), right.getAttributeName())) { throw JPQLException.invalidCollectionNavigation( context.getQueryInfo(), right.getLine(), right.getColumn(), this.getAsString(), right.getAttributeName()); } } }
/** * INTERNAL * Checks whether the left hand side of this dot node is navigable. */ private void checkNavigation(Node node, ParseTreeContext context) { TypeHelper typeHelper = context.getTypeHelper(); // Checks whether the type of the dot node allows a navigation. Object type = node.getType(); if (!typeHelper.isEntityClass(type) && !typeHelper.isEmbeddable(type) && !typeHelper.isEnumType(type)) { throw JPQLException.invalidNavigation( context.getQueryInfo(), node.getLine(), node.getColumn(), this.getAsString(), node.getAsString(), typeHelper.getTypeName(type)); } // Special check to disallow collection valued relationships if (node.isDotNode()) { Node left = node.getLeft(); AttributeNode right = (AttributeNode)node.getRight(); if (typeHelper.isCollectionValuedRelationship( left.getType(), right.getAttributeName())) { throw JPQLException.invalidCollectionNavigation( context.getQueryInfo(), right.getLine(), right.getColumn(), this.getAsString(), right.getAttributeName()); } } }
/** * INTERNAL * Checks whether the left hand side of this dot node is navigable. */ private void checkNavigation(Node node, ParseTreeContext context) { TypeHelper typeHelper = context.getTypeHelper(); // Checks whether the type of the dot node allows a navigation. Object type = node.getType(); if (!typeHelper.isEntityClass(type) && !typeHelper.isEmbeddable(type) && !typeHelper.isEnumType(type)) { throw JPQLException.invalidNavigation( context.getQueryInfo(), node.getLine(), node.getColumn(), this.getAsString(), node.getAsString(), typeHelper.getTypeName(type)); } // Special check to disallow collection valued relationships if (node.isDotNode()) { Node left = node.getLeft(); AttributeNode right = (AttributeNode)node.getRight(); if (typeHelper.isCollectionValuedRelationship( left.getType(), right.getAttributeName())) { throw JPQLException.invalidCollectionNavigation( context.getQueryInfo(), right.getLine(), right.getColumn(), this.getAsString(), right.getAttributeName()); } } }