类javax.persistence.criteria.Fetch源码实例Demo

下面列出了怎么用javax.persistence.criteria.Fetch的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: QueryStructure.java
@SuppressWarnings({ "unchecked" })
private void renderFetches(
		StringBuilder jpaqlQuery,
		RenderingContext renderingContext,
		Collection<Fetch> fetches) {
	if ( fetches == null ) {
		return;
	}

	for ( Fetch fetch : fetches ) {
		( (FromImplementor) fetch ).prepareAlias( renderingContext );
		jpaqlQuery.append( renderJoinType( fetch.getJoinType() ) )
				.append( "fetch " )
				.append( ( (FromImplementor) fetch ).renderTableExpression( renderingContext ) );

		renderFetches( jpaqlQuery, renderingContext, fetch.getFetches() );
	}
}
 
源代码2 项目: crnk-framework   文件: QueryUtil.java
private static boolean containsMultiRelationFetch(Set<?> fetches) {
	for (Object fetchObj : fetches) {
		Fetch<?, ?> fetch = (Fetch<?, ?>) fetchObj;

		Attribute<?, ?> attr = fetch.getAttribute();
		if (attr.isAssociation() && attr.isCollection())
			return true;

		if (containsMultiRelationFetch(fetch.getFetches()))
			return true;
	}
	return false;
}
 
源代码3 项目: crnk-framework   文件: QueryUtil.java
private static boolean containsMultiRelationJoin(Set<?> fetches) {
	for (Object fetchObj : fetches) {
		Fetch<?, ?> fetch = (Fetch<?, ?>) fetchObj;
		Attribute<?, ?> attr = fetch.getAttribute();
		if (attr.isAssociation() && attr.isCollection())
			return true;

		if (containsMultiRelationFetch(fetch.getFetches()))
			return true;
	}
	return false;
}
 
源代码4 项目: lams   文件: AbstractFromImpl.java
@Override
public void addFetch(Fetch<X, ?> fetch) {
	if ( fetches == null ) {
		fetches = new LinkedHashSet<Fetch<X, ?>>();
	}
	fetches.add( fetch );
}
 
源代码5 项目: lams   文件: AbstractFromImpl.java
@Override
@SuppressWarnings({"unchecked"})
public Set<Fetch<X, ?>> getFetches() {
	return fetches == null
			? Collections.EMPTY_SET
			: fetches;
}
 
源代码6 项目: lams   文件: AbstractFromImpl.java
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> Fetch<X, Y> fetch(String attributeName, JoinType jt) {
	if ( !canBeFetchSource() ) {
		throw illegalFetch();
	}

	Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( attribute.isCollection() ) {
		return (Fetch<X, Y>) fetch( (PluralAttribute) attribute, jt );
	}
	else {
		return (Fetch<X, Y>) fetch( (SingularAttribute) attribute, jt );
	}
}
 
源代码7 项目: katharsis-framework   文件: QueryUtil.java
private static boolean containsMultiRelationFetch(Set<?> fetches) {
  for (Object fetchObj : fetches) {
    Fetch<?, ?> fetch = (Fetch<?, ?>) fetchObj;

    Attribute<?, ?> attr = fetch.getAttribute();
    if (attr.isAssociation() && attr.isCollection())
      return true;

    if (containsMultiRelationFetch(fetch.getFetches()))
      return true;
  }
  return false;
}
 
源代码8 项目: katharsis-framework   文件: QueryUtil.java
private static boolean containsMultiRelationJoin(Set<?> fetches) {
  for (Object fetchObj : fetches) {
    Fetch<?, ?> fetch = (Fetch<?, ?>) fetchObj;
    Attribute<?, ?> attr = fetch.getAttribute();
    if (attr.isAssociation() && attr.isCollection())
      return true;

    if (containsMultiRelationFetch(fetch.getFetches()))
      return true;
  }
  return false;
}
 
源代码9 项目: gazpachoquest   文件: JpaUtil.java
/**
 * Convert the passed propertyPath into a JPA path.
 * <p>
 * Note: JPA will do joins if the property is in an associated entity.
 */
@SuppressWarnings("unchecked")
public static <E, F> Path<F> getPath(Root<E> root, List<Attribute<?, ?>> attributes) {
    Path<?> path = root;
    for (Attribute<?, ?> attribute : attributes) {
        boolean found = false;
        // handle case when order on already fetched attribute
        for (Fetch<E, ?> fetch : root.getFetches()) {
            if (attribute.getName().equals(fetch.getAttribute().getName()) && (fetch instanceof Join<?, ?>)) {
                path = (Join<E, ?>) fetch;
                found = true;
                break;
            }
        }
        for (Join<E, ?> join : root.getJoins()) {
            if (attribute.getName().equals(join.getAttribute().getName())) {
                path = join;
                found = true;
                break;
            }
        }
        if (!found) {
            path = path.get(attribute.getName());
        }
    }
    return (Path<F>) path;
}
 
源代码10 项目: jdal   文件: JpaUtils.java
/**
 * Copy Fetches
 * @param from source From
 * @param to destination From
 */
public static void copyFetches(From<?, ?> from, From<?, ?> to) {
	for (Fetch<?, ?> f : from.getFetches()) {
		Fetch<?, ?> toFetch = to.fetch(f.getAttribute().getName());
		copyFetches(f, toFetch);
	}
}
 
源代码11 项目: jdal   文件: JpaUtils.java
/**
 * Copy Fetches
 * @param from source Fetch
 * @param to dest Fetch
 */
public static void copyFetches(Fetch<?, ?> from, Fetch<?, ?> to) {
	for (Fetch<?, ?> f : from.getFetches()) {
		Fetch<?, ?> toFetch = to.fetch(f.getAttribute().getName());
		// recursively copy fetches
		copyFetches(f, toFetch);
	}
}
 
源代码12 项目: lams   文件: AbstractFromImpl.java
@Override
public void addFetch(Fetch<X, ?> fetch) {
	throw new UnsupportedOperationException( "Cannot define fetch from a subquery correlation" );
}
 
源代码13 项目: lams   文件: AbstractFromImpl.java
@Override
public <Y> Fetch<X, Y> fetch(SingularAttribute<? super X, Y> singularAttribute) {
	return fetch( singularAttribute, DEFAULT_JOIN_TYPE );
}
 
源代码14 项目: lams   文件: AbstractFromImpl.java
@Override
public <Y> Fetch<X, Y> fetch(PluralAttribute<? super X, ?, Y> pluralAttribute) {
	return fetch( pluralAttribute, DEFAULT_JOIN_TYPE );
}
 
源代码15 项目: lams   文件: AbstractFromImpl.java
@Override
public <X, Y> Fetch<X, Y> fetch(String attributeName) {
	return fetch( attributeName, DEFAULT_JOIN_TYPE );
}
 
源代码16 项目: lams   文件: AbstractFromImpl.java
public void addFetch(Fetch<X, ?> fetch); 
 类所在包
 类方法
 同包方法