if (trimmedPath.regionMatches(true, 0, indexStart, 0, indexStart.length())) { collectionArgumentStart = indexStart.length(); collectionFunction = new ListIndexAttribute<>(type.getList(collectionName)); } else if (trimmedPath.regionMatches(true, 0, keyStart, 0, keyStart.length())) { collectionArgumentStart = keyStart.length();
if (trimmedPath.regionMatches(true, 0, indexStart, 0, indexStart.length())) { collectionArgumentStart = indexStart.length(); collectionFunction = new ListIndexAttribute<>(type.getList(collectionName)); } else if (trimmedPath.regionMatches(true, 0, keyStart, 0, keyStart.length())) { collectionArgumentStart = keyStart.length();
@Override public void visit(ListIndexExpression expression) { expression.getPath().accept(this); Class<?> type = currentPosition.getRealCurrentClass(); if (!List.class.isAssignableFrom(type)) { invalid(expression, "Does not resolve to java.util.List!"); } else { currentPosition.setAttribute(new ListIndexAttribute<>((ListAttribute<?, ?>) currentPosition.getAttribute())); currentPosition.setValueType(null); currentPosition.setKeyType(metamodel.type(Integer.class)); } }
@Override public void visit(ListIndexExpression expression) { expression.getPath().accept(this); Class<?> type = currentPosition.getRealCurrentClass(); if (!List.class.isAssignableFrom(type)) { invalid(expression, "Does not resolve to java.util.List!"); } else { currentPosition.setAttribute(new ListIndexAttribute<>((ListAttribute<?, ?>) currentPosition.getAttribute())); currentPosition.setValueType(null); currentPosition.setKeyType(metamodel.type(Integer.class)); } }
@Override public void visit(ListIndexExpression expression) { expression.getPath().accept(this); if (!(currentPosition.getAttribute() instanceof ListAttribute<?, ?>)) { invalid(expression, "Does not resolve to java.util.List!"); } else { currentPosition.setAttribute(new ListIndexAttribute<>((ListAttribute<?, ?>) currentPosition.getAttribute())); currentPosition.setCurrentType(metamodel.type(Integer.class)); } }
private JoinNode joinListIndex(ListIndexExpression listIndexExpression, String alias, ClauseType fromClause, Set<String> currentlyResolvingAliases, boolean fromSubquery, boolean fromSelectAlias, boolean joinRequired, boolean fetch, boolean implicit, boolean defaultJoin) { implicitJoin(listIndexExpression.getPath(), true, true, null, fromClause, null, currentlyResolvingAliases, fromSubquery, fromSelectAlias, joinRequired, false, fetch, false); JoinNode current = (JoinNode) listIndexExpression.getPath().getBaseNode(); String joinRelationName = "INDEX(" + current.getParentTreeNode().getRelationName() + ")"; ListAttribute<?, ?> listAttribute = (ListAttribute<?, ?>) current.getParentTreeNode().getAttribute(); Attribute<?, ?> indexAttribute = new ListIndexAttribute<>(listAttribute); String aliasToUse = alias == null ? current.getParentTreeNode().getRelationName().replaceAll("\\.", "_") + "_index" : alias; Type<?> joinRelationType = metamodel.type(Integer.class); current = getOrCreate(current, joinRelationName, joinRelationType, null, aliasToUse, JoinType.LEFT, "Ambiguous implicit join", implicit, true, indexAttribute); return current; }