/** * AND's provided expressions to the existing WHERE clause expression. * * @return this object */ public ObjectSelect<T> and(Collection<Expression> expressions) { if (expressions == null || expressions.isEmpty()) { return this; } Collection<Expression> all; if (where != null) { all = new ArrayList<>(expressions.size() + 1); all.add(where); all.addAll(expressions); } else { all = expressions; } where = ExpressionFactory.and(all); replacementQuery = null; return this; }
/** * AND's provided expressions to the existing WHERE or HAVING clause expression. * * @return this object */ public ColumnSelect<T> and(Collection<Expression> expressions) { if (expressions == null || expressions.isEmpty()) { return this; } Collection<Expression> all; Expression activeExpression = getActiveExpression(); if (activeExpression != null) { all = new ArrayList<>(expressions.size() + 1); all.add(activeExpression); all.addAll(expressions); } else { all = expressions; } setActiveExpression(ExpressionFactory.and(all)); return this; }
private Expression buildIdQualifer(AgEntity<?> entity, AgObjectId id) { Collection<AgAttribute> idAttributes = entity.getIds(); if (idAttributes.size() != id.size()) { throw new AgException(Response.Status.BAD_REQUEST, "Wrong ID size: expected " + idAttributes.size() + ", got: " + id.size()); } Collection<Expression> qualifiers = new ArrayList<>(); for (AgAttribute idAttribute : idAttributes) { Object idValue = id.get(idAttribute.getName()); if (idValue == null) { throw new AgException(Response.Status.BAD_REQUEST, "Failed to build a Cayenne qualifier for entity " + entity.getName() + ": one of the entity's ID parts is missing in this ID: " + idAttribute.getName()); } if (idAttribute instanceof AgPersistentAttribute) { qualifiers.add(ExpressionFactory.matchDbExp( ((AgPersistentAttribute) idAttribute).getColumnName(), idValue)); } else { // can be non-persistent attribute if assembled from @AgId by AgEntityBuilder qualifiers.add(ExpressionFactory.matchDbExp(idAttribute.getName(), idValue)); } } return ExpressionFactory.and(qualifiers); }
return ExpressionFactory.and(expressions); } else { return ExpressionFactory.matchDbExp(objRelationship.getReverseDbRelationshipPath(), id.get());