@Override @SuppressWarnings("hiding") public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) { return getWrapped().joinMap(attributeName, jt); }
@Override @SuppressWarnings("hiding") public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName) { return getWrapped().joinMap(attributeName); }
public static Predicate<BuildRecord> withAttribute(String key, String value) { return (root, query, cb) -> { MapJoin<Object, Object, Object> mapJoinAttributes = root.joinMap(BuildRecord_.attributes.getName()); return query.where(cb.and(cb.equal(mapJoinAttributes.key(), key), cb.equal(mapJoinAttributes.value(), value))).getRestriction(); }; }
predicates.add(root.join("scopes").get("id").in(value)); } else if (name.startsWith("config:")) { predicates.add(root.joinMap("config").key().in(name.substring("config:".length()))); predicates.add(builder.like(root.joinMap("config").value().as(String.class), "%" + value[0] + "%")); } else { predicates.add(builder.like(builder.lower(root.get(name)), "%" + value[0].toLowerCase() + "%"));
MapJoin<StockShiftUnit, Product, ProductBatch> amountJoin = root.joinMap("amounts"); amountJoin = amountJoin.on(cb.equal(amountJoin.key(), product));
@Override public Specification<StockShiftUnit> specification() { return (root, query, cb) -> { final Join<StockShiftUnit, Depot> stockShiftUnitDepotJoin = StockShiftUnit.destinationJoin(root); Predicate predicate = cb.and( stockShiftUnitDepotJoin.isNotNull(), StockShiftUnit.originJoin(root).isNull() ); if (!StringUtils.isEmpty(mobile)) predicate = cb.and(predicate, cb.like(Depot.mobile(stockShiftUnitDepotJoin) , "%" + mobile + "%")); if (depotId != null) predicate = cb.and(predicate, cb.equal(stockShiftUnitDepotJoin.get("id"), depotId)); // productCode 包含这个商品 if (!StringUtils.isEmpty(productCode)) { MapJoin<StockShiftUnit, Product, ProductBatch> amountJoin = root.joinMap("amounts"); predicate = cb.and(predicate, cb.equal(amountJoin.key().get("code"), productCode)); } if (orderDate != null) { predicate = cb.and( predicate , JpaFunctionUtils.dateEqual(cb, StockShiftUnit.createDate(root), orderDate)); } return predicate; }; } };