Esempio n. 1
0
  @SuppressWarnings("unchecked")
  static <T> Expression<T> toExpressionRecursively(From<?, ?> from, PropertyPath property) {

    Bindable<?> propertyPathModel = null;
    if (from.getModel() instanceof ManagedType) {
      /*
       *  Avoid calling from.get(...) because this triggers the generation of an inner-join instead
       *  of and outer-join in eclipse-link.
       *  See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=413892
       */
      propertyPathModel =
          (Bindable<?>) ((ManagedType<?>) from.getModel()).getAttribute(property.getSegment());
    } else {
      propertyPathModel = from.get(property.getSegment()).getModel();
    }

    if (property.isCollection() || requiresJoin(propertyPathModel)) {
      Join<?, ?> join = getOrCreateJoin(from, property.getSegment());
      return (Expression<T>)
          (property.hasNext() ? toExpressionRecursively(join, property.next()) : join);
    } else {
      Path<Object> path = from.get(property.getSegment());
      return (Expression<T>)
          (property.hasNext() ? toExpressionRecursively(path, property.next()) : path);
    }
  }
Esempio n. 2
0
  @SuppressWarnings("unchecked")
  static <T> Expression<T> toExpressionRecursively(From<?, ?> from, PropertyPath property) {

    Bindable<?> propertyPathModel = null;
    Bindable<?> model = from.getModel();
    String segment = property.getSegment();

    if (model instanceof ManagedType) {

      /*
       *  Required to keep support for EclipseLink 2.4.x. TODO: Remove once we drop that (probably Dijkstra M1)
       *  See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=413892
       */
      propertyPathModel = (Bindable<?>) ((ManagedType<?>) model).getAttribute(segment);
    } else {
      propertyPathModel = from.get(segment).getModel();
    }

    if (requiresJoin(propertyPathModel, model instanceof PluralAttribute)
        && !isAlreadyFetched(from, segment)) {
      Join<?, ?> join = getOrCreateJoin(from, segment);
      return (Expression<T>)
          (property.hasNext() ? toExpressionRecursively(join, property.next()) : join);
    } else {
      Path<Object> path = from.get(segment);
      return (Expression<T>)
          (property.hasNext() ? toExpressionRecursively(path, property.next()) : path);
    }
  }
Esempio n. 3
0
  static Expression<Object> toExpressionRecursively(Path<Object> path, PropertyPath property) {

    Path<Object> result = path.get(property.getSegment());
    return property.hasNext() ? toExpressionRecursively(result, property.next()) : result;
  }