当前位置: 首页>>代码示例>>Java>>正文


Java From.join方法代码示例

本文整理汇总了Java中javax.persistence.criteria.From.join方法的典型用法代码示例。如果您正苦于以下问题:Java From.join方法的具体用法?Java From.join怎么用?Java From.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.persistence.criteria.From的用法示例。


在下文中一共展示了From.join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: join

import javax.persistence.criteria.From; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Nonnull
public static <T, U> Join<T, U> join(
        @Nonnull final From<?, T> from, @Nonnull final PluralAttribute<? super T, ?, U> attribute) {

    Objects.requireNonNull(from, "from is null");
    Objects.requireNonNull(attribute, "attribute is null");

    if (attribute instanceof CollectionAttribute) {
        return from.join((CollectionAttribute<T, U>) attribute);
    }
    if (attribute instanceof SetAttribute) {
        return from.join((SetAttribute<T, U>) attribute);
    }
    if (attribute instanceof ListAttribute) {
        return from.join((ListAttribute<T, U>) attribute);
    }
    if (attribute instanceof MapAttribute) {
        return from.join((MapAttribute<T, ?, U>) attribute);
    }

    // Should never end up here.
    throw new IllegalArgumentException();
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:25,代码来源:CriteriaUtils.java

示例2: copyJoins

import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
 * @return last possibly used alias
 */
private int copyJoins(From<?, ?> from, From<?, ?> to, int counter) {
    for (Join<?, ?> join : sort(comparator, from.getJoins())) {
        Attribute<?, ?> attr = join.getAttribute();
        // Hibern fails with String-bases api; Join.join(String, JoinType)
        @SuppressWarnings({ "rawtypes", "unchecked" })
        Join<Object, Object> j = attr instanceof SingularAttribute ? to.join((SingularAttribute) join.getAttribute(), join.getJoinType()) :
            attr instanceof CollectionAttribute ? to.join((CollectionAttribute) join.getAttribute(), join.getJoinType()) :
            attr instanceof SetAttribute ? to.join((SetAttribute) join.getAttribute(), join.getJoinType()) :
            attr instanceof ListAttribute ? to.join((ListAttribute) join.getAttribute(), join.getJoinType()) :
            attr instanceof MapAttribute ? to.join((MapAttribute) join.getAttribute(), join.getJoinType()) :
            to.join((CollectionAttribute) join.getAttribute(), join.getJoinType());
        copyAlias(join, j, ++counter);
        counter = copyJoins(join, j, ++counter);
    }
    copyFetches(from, to);
    return counter;
}
 
开发者ID:solita,项目名称:query-utils,代码行数:21,代码来源:JpaCriteriaCopy.java

示例3: getExpression

import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
 * Cree une expression Criteria API avec l'atribut de l'entité passé en parametre
 * 
 * @param root
 *            entité JPA contenant le champ
 * @param columnData
 *            nom du champ
 * @param clazz
 *            class du champ
 * @param <S>
 *            type du champ
 * @return l'expression de l'atribut
 */
public static <S> Path<S> getExpression(final Root<?> root, final String columnData, final Class<S> clazz) {
    if (!columnData.contains(DatatableSpecification.ATTRIBUTE_SEPARATOR)) {
        // columnData is like "attribute" so nothing particular to do
        return root.get(columnData);
    }
    // columnData is like "joinedEntity.attribute" so add a join clause
    final String[] values = columnData.split(DatatableSpecification.ESCAPED_ATTRIBUTE_SEPARATOR);
    final Attribute<?, ?> attribute = root.getModel().getAttribute(values[0]);
    if (attribute == null) {
        throw new IllegalArgumentException(
            "Colonne '" + values[0] + "' (" + columnData + ") introuvable depuis l'entité '" + root.getJavaType()
                + "'");
    }
    if (attribute.getPersistentAttributeType() == PersistentAttributeType.EMBEDDED) {
        // with @Embedded attribute
        return root.get(values[0]).get(values[1]);
    }
    From<?, ?> from = root;
    for (int i = 0; i < values.length - 1; i++) {

        Join<?, ?> join = null;
        for (final Join<?, ?> joinCandidate : from.getJoins()) {
            if (joinCandidate.getAttribute().getName().equals(values[i])) {
                // LOGGER.debug("Trouve joint d'entite: '{}'", values[i]);
                join = joinCandidate;
            }
        }
        if (join == null) {
            // LOGGER.debug("Joigant entite '{}'...", values[i]);
            join = from.join(values[i], JoinType.INNER);
        }
        from = join;
    }
    return from.get(values[values.length - 1]);
}
 
开发者ID:andresoviedo,项目名称:datatable-java,代码行数:49,代码来源:DatatableHelper.java

示例4: copyJoins

import javax.persistence.criteria.From; //导入方法依赖的package包/类
private void copyJoins(From<?, ?> from, From<?, ?> to) {
	for (Join<?, ?> join : from.getJoins()) {
		Join<?, ?> toJoin = to.join(join.getAttribute().getName(), join.getJoinType());
		toJoin.alias(getAlias(join));
		copyJoins(join, toJoin);
	}
	for (Fetch<?, ?> fetch : from.getFetches()) {
		Fetch<?, ?> toFetch = to.fetch(fetch.getAttribute().getName());
		copyFetches(fetch, toFetch);
	}
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:12,代码来源:BaseDaoImpl.java

示例5: doJoin

import javax.persistence.criteria.From; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public From<?, ?> doJoin(MetaAttribute targetAttr, JoinType joinType, From<?, ?> parent) {
	if (targetAttr instanceof MetaComputedAttribute) {
		MetaComputedAttribute projAttr = (MetaComputedAttribute) targetAttr;
		@SuppressWarnings("rawtypes")
		JpaCriteriaExpressionFactory expressionFactory = (JpaCriteriaExpressionFactory<?>) queryImpl.getComputedAttrs()
				.get(projAttr);

		return (From<?, ?>) expressionFactory.getExpression(parent, getCriteriaQuery());
	}
	else {
		return parent.join(targetAttr.getName(), joinType);
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:16,代码来源:JpaCriteriaQueryBackend.java

示例6: visit

import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public boolean visit(JpqlInnerJoin node, CriteriaHolder query) {
    Path path = new Path(node.jjtGetChild(0).toString());
    Alias alias = getAlias(node);
    From<?, ?> from = query.getFrom(path.getRootAlias());
    Join<Object, Object> join = from.join(path.getSubpath(), JoinType.INNER);
    if (alias != null) {
        join.alias(alias.getName());
    }
    return false;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:14,代码来源:CriteriaVisitor.java

示例7: getQueryRestriction

import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
 * TODO This method may be bformat specific. Consider creating new abstract class to group all bformat related DAO. Builds a query restriction predicate for
 * the specified business object format entity as per business object format key values.
 *
 * @param builder the criteria builder
 * @param businessObjectFormatEntity the business object format entity that appears in the from clause
 * @param fileTypeEntity the file type entity that appears in the from clause
 * @param businessObjectDefinitionEntity the business object definition entity that appears in the from clause
 * @param businessObjectFormatKey the business object format key
 * @param ignoreBusinessObjectFormatVersion specifies whether to ignore the business object format version when building the predicate
 *
 * @return the query restriction predicate
 */
protected Predicate getQueryRestriction(CriteriaBuilder builder, From<?, BusinessObjectFormatEntity> businessObjectFormatEntity,
    From<?, FileTypeEntity> fileTypeEntity, From<?, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity,
    BusinessObjectFormatKey businessObjectFormatKey, boolean ignoreBusinessObjectFormatVersion)
{
    // Join to the other tables we can filter on.
    Join<BusinessObjectDefinitionEntity, NamespaceEntity> namespaceEntity = businessObjectDefinitionEntity.join(BusinessObjectDefinitionEntity_.namespace);

    // Create the standard restrictions based on the business object format key values (i.e. the standard where clauses).

    // Create a restriction on namespace code.
    Predicate predicate = builder.equal(builder.upper(namespaceEntity.get(NamespaceEntity_.code)), businessObjectFormatKey.getNamespace().toUpperCase());

    // Create and append a restriction on business object definition name.
    predicate = builder.and(predicate, builder.equal(builder.upper(businessObjectDefinitionEntity.get(BusinessObjectDefinitionEntity_.name)),
        businessObjectFormatKey.getBusinessObjectDefinitionName().toUpperCase()));

    // Create and append a restriction on business object format usage.
    predicate = builder.and(predicate, builder.equal(builder.upper(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.usage)),
        businessObjectFormatKey.getBusinessObjectFormatUsage().toUpperCase()));

    // Create and append a restriction on business object format file type.
    predicate = builder.and(predicate,
        builder.equal(builder.upper(fileTypeEntity.get(FileTypeEntity_.code)), businessObjectFormatKey.getBusinessObjectFormatFileType().toUpperCase()));

    // If specified, create and append a restriction on business object format version.
    if (!ignoreBusinessObjectFormatVersion && businessObjectFormatKey.getBusinessObjectFormatVersion() != null)
    {
        predicate = builder.and(predicate, builder.equal(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.businessObjectFormatVersion),
            businessObjectFormatKey.getBusinessObjectFormatVersion()));
    }

    return predicate;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:47,代码来源:AbstractHerdDao.java

示例8: getFieldPath

import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
 * Resolves the Path for a field in the persistence layer and joins the
 * required models. This operation is part of a tree traversal through
 * an RSQL expression. It creates for every field that is not part of
 * the root model a join to the foreign model. This behavior is
 * optimized when several joins happen directly under an OR node in the
 * traversed tree. The same foreign model is only joined once.
 *
 * Example: tags.name==M;(tags.name==A,tags.name==B,tags.name==C) This
 * example joins the tags model only twice, because for the OR node in
 * brackets only one join is used.
 *
 * @param enumField
 *            field from a FieldNameProvider to resolve on the
 *            persistence layer
 * @param finalProperty
 *            dot notated field path
 * @return the Path for a field
 */
private Path<Object> getFieldPath(final A enumField, final String finalProperty) {
    Path<Object> fieldPath = null;
    final String[] split = finalProperty.split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);

    for (int i = 0; i < split.length; i++) {
        final boolean isMapKeyField = enumField.isMap() && i == (split.length - 1);
        if (isMapKeyField) {
            return fieldPath;
        }

        final String fieldNameSplit = split[i];
        fieldPath = (fieldPath != null) ? fieldPath.get(fieldNameSplit) : root.get(fieldNameSplit);
        if (fieldPath instanceof PluralJoin) {
            final Join<Object, ?> join = (Join<Object, ?>) fieldPath;
            final From<?, Object> joinParent = join.getParent();
            final Optional<Join<Object, Object>> currentJoinOfType = findCurrentJoinOfType(join.getJavaType());
            if (currentJoinOfType.isPresent() && isOrLevel) {
                // remove the additional join and use the existing one
                joinParent.getJoins().remove(join);
                fieldPath = currentJoinOfType.get();
            } else {
                final Join<Object, Object> newJoin = joinParent.join(fieldNameSplit, JoinType.LEFT);
                addCurrentJoin(newJoin);
                fieldPath = newJoin;
            }

        }
    }
    return fieldPath;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:50,代码来源:RSQLUtility.java

示例9: getPath

import javax.persistence.criteria.From; //导入方法依赖的package包/类
protected <T, S> Path<?> getPath(From<T, S> root, String name) {
	int index = name.indexOf(".");
	if (index > 0 ) {
		String attribute = name.substring(0, index);
		From<S, ?> join = getJoin(attribute, root.getJoins());
		if (join == null) {
			join = root.join(attribute);
		}
		return getPath(join, name.substring(index + 1));
	} else {
		return root.get(name);
	}
}
 
开发者ID:ActiveJpa,项目名称:activejpa,代码行数:14,代码来源:AbstractConstruct.java

示例10: copyJoins

import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
 * Copy Joins
 * @param from source Join
 * @param to destination Join
 */
public static void copyJoins(From<?, ?> from, From<?, ?> to) {
	for (Join<?, ?> j : from.getJoins()) {
		Join<?, ?> toJoin = to.join(j.getAttribute().getName(), j.getJoinType());
		toJoin.alias(getOrCreateAlias(j));
	
		copyJoins(j, toJoin);
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:14,代码来源:JpaUtils.java

示例11: joinSingular

import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinSingular(From path)
{
    if (joinType == null)
    {
        return path.join(singular);
    }
    return path.join(singular, joinType);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:9,代码来源:JoinBuilder.java

示例12: joinList

import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinList(From path)
{
    if (joinType == null)
    {
        return path.join(list);
    }
    return path.join(list, joinType);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:9,代码来源:JoinBuilder.java

示例13: joinCollection

import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinCollection(From path)
{
    if (joinType == null)
    {
        return path.join(collection);
    }
    return path.join(collection, joinType);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:9,代码来源:JoinBuilder.java

示例14: joinSet

import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinSet(From path)
{
    if (joinType == null)
    {
        return path.join(set);
    }
    return path.join(set, joinType);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:9,代码来源:JoinBuilder.java

示例15: joinMap

import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinMap(From path)
{
    if (joinType == null)
    {
        return path.join(map);
    }
    return path.join(map, joinType);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:9,代码来源:JoinBuilder.java


注:本文中的javax.persistence.criteria.From.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。