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


Java Attribute.isCollection方法代码示例

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


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

示例1: filter

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
public Attribute<?, ?> filter() {
    Type<?> type = forModel(metamodel).filter(rootType);
    Attribute<?, ?> result = null;
    for (int i = 1; i < pathElements.length; i++) {
        if (!(type instanceof ManagedType)) {
            throw new PersistenceException("Cannot navigate through simple property "
                    + pathElements[i] + " of type " + type.getJavaType());
        }
        result = ((ManagedType<?>)type).getAttribute(pathElements[i]);
        if (result.isCollection()) {
            type = ((PluralAttribute<?, ?, ?>)result).getElementType();
        } else {
            type = ((SingularAttribute<?, ?>)result).getType();
        }
    }
    return result;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:18,代码来源:TypeDefinition.java

示例2: visitJoin

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
public boolean visitJoin(Node node, Set<TypeDefinition> typeDefinitions) {
    if (node.jjtGetNumChildren() != 2) {
        return false;
    }
    Node pathNode = node.jjtGetChild(0);
    Node aliasNode = node.jjtGetChild(1);
    Alias rootAlias = new Alias(pathNode.jjtGetChild(0).toString());
    Class<?> rootType = getType(rootAlias, typeDefinitions);
    ManagedType<?> managedType = forModel(metamodel).filter(rootType);
    for (int i = 1; i < pathNode.jjtGetNumChildren(); i++) {
        Attribute<?, ?> attribute = managedType.getAttribute(pathNode.jjtGetChild(i).toString());
        if (attribute.getPersistentAttributeType() == PersistentAttributeType.BASIC) {
            throw new PersistenceException("Cannot navigate through basic property "
                    + pathNode.jjtGetChild(i) + " of path " + pathNode);
        }
        if (attribute.isCollection()) {
            PluralAttribute<?, ?, ?> pluralAttribute = (PluralAttribute<?, ?, ?>)attribute;
            managedType = (ManagedType<?>)pluralAttribute.getElementType();
        } else {
            managedType = (ManagedType<?>)((SingularAttribute)attribute).getType();
        }
    }
    typeDefinitions.add(new TypeDefinition(new Alias(aliasNode.toString()), managedType.getJavaType()));
    return false;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:26,代码来源:MappingEvaluator.java

示例3: copyProperties

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
/**
 * Copies the persistent properties from the source to the destination entity
 */
public void copyProperties(final Entity source, final Entity dest) {
    if (source == null || dest == null) {
        return;
    }

    final ManagedType<?> metaData = getClassMetamodel(source);
    for (Attribute<?, ?> attribute : metaData.getAttributes()) {
        // Skip the collections
        if (attribute.isCollection()) {
            PropertyHelper.set(dest, attribute.getName(), null);
        } else {
            PropertyHelper.set(dest, attribute.getName(), PropertyHelper.get(source, attribute.getName()));
        }
    }

}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:20,代码来源:JpaQueryHandler.java

示例4: containsMultiRelationFetch

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
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;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:14,代码来源:QueryUtil.java

示例5: containsMultiRelationJoin

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
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;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:13,代码来源:QueryUtil.java

示例6: containsMultiRelationFetch

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
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;
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:14,代码来源:QueryUtil.java

示例7: containsMultiRelationJoin

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
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;
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:13,代码来源:QueryUtil.java

示例8: transform

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
@Override
protected ManagedType<?> transform(TypeDefinition typeDefinition) {
    if (!path.hasSubpath()) {
        return forModel(metamodel).filter(typeDefinition.getType());
    }
    Attribute<?, ?> attribute = (Attribute<?, ?>)filter.transform(typeDefinition);
    if (attribute.isCollection()) {
        return (ManagedType<?>)((PluralAttribute<?, ?, ?>)attribute).getElementType();
    } else {
        return (ManagedType<?>)((SingularAttribute<?, ?>)attribute).getType();
    }
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:13,代码来源:TypeDefinition.java

示例9: resolveReference

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
private void resolveReference(final Object entity, Attribute<?, ?> attribute) {
     if (attribute.isCollection() && !Map.class.isAssignableFrom(attribute.getJavaType())) {
        // Properties that are collections of other entities
        final Collection<?> current = PropertyHelper.get(entity, attribute.getName());
        if (current != null) {
            boolean isEntityCollection = true;
            final Collection<Entity> resolved = ClassHelper.instantiate(current.getClass());
            for (final Object object : current) {
                if (object != null && !(object instanceof Entity)) {
                    isEntityCollection = false;
                    break;
                }
                Entity e = (Entity) object;
                if (object instanceof EntityReference) {
                    e = entityManager.find(EntityHelper.getRealClass(e), e.getId());
                }
                resolved.add(e);
            }
            if (isEntityCollection) {
                PropertyHelper.set(entity, attribute.getName(), resolved);
            }
        }
    } else if (attribute.isAssociation() && !Map.class.isAssignableFrom(attribute.getJavaType())) {
        // Properties that are relationships to other entities
        Entity rel = PropertyHelper.get(entity, attribute.getName());
        if (rel instanceof EntityReference) {
            rel = entityManager.find(EntityHelper.getRealClass(rel), rel.getId());
            PropertyHelper.set(entity, attribute.getName(), rel);
        }
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:32,代码来源:JpaQueryHandler.java

示例10: join

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> JpaAttributeJoin<X, Y> join(String attributeName, JoinType jt) {
	if ( !canBeJoinSource() ) {
		throw illegalJoin();
	}

	if ( jt.equals( JoinType.RIGHT ) ) {
		throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
	}

	final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( attribute.isCollection() ) {
		final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
		if ( PluralAttribute.CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
			return (JpaAttributeJoin<X, Y>) join( (CollectionAttribute) attribute, jt );
		}
		else if ( PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
			return (JpaAttributeJoin<X, Y>) join( (ListAttribute) attribute, jt );
		}
		else if ( PluralAttribute.CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
			return (JpaAttributeJoin<X, Y>) join( (SetAttribute) attribute, jt );
		}
		else {
			return (JpaAttributeJoin<X, Y>) join( (MapAttribute) attribute, jt );
		}
	}
	else {
		return (JpaAttributeJoin<X, Y>) join( (SingularAttribute) attribute, jt );
	}
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:32,代码来源:AbstractFromImpl.java

示例11: joinCollection

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> JpaCollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) {
	final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( !attribute.isCollection() ) {
		throw new IllegalArgumentException( "Requested attribute was not a collection" );
	}

	final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
	if ( !PluralAttribute.CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
		throw new IllegalArgumentException( "Requested attribute was not a collection" );
	}

	return (JpaCollectionJoin<X, Y>) join( (CollectionAttribute) attribute, jt );
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:16,代码来源:AbstractFromImpl.java

示例12: joinSet

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> JpaSetJoin<X, Y> joinSet(String attributeName, JoinType jt) {
	final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( !attribute.isCollection() ) {
		throw new IllegalArgumentException( "Requested attribute was not a set" );
	}

	final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
	if ( !PluralAttribute.CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
		throw new IllegalArgumentException( "Requested attribute was not a set" );
	}

	return (JpaSetJoin<X, Y>) join( (SetAttribute) attribute, jt );
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:16,代码来源:AbstractFromImpl.java

示例13: joinList

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> JpaListJoin<X, Y> joinList(String attributeName, JoinType jt) {
	final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( !attribute.isCollection() ) {
		throw new IllegalArgumentException( "Requested attribute was not a list" );
	}

	final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
	if ( !PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
		throw new IllegalArgumentException( "Requested attribute was not a list" );
	}

	return (JpaListJoin<X, Y>) join( (ListAttribute) attribute, jt );
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:16,代码来源:AbstractFromImpl.java

示例14: joinMap

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public <X, K, V> JpaMapJoin<X, K, V> joinMap(String attributeName, JoinType jt) {
	final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( !attribute.isCollection() ) {
		throw new IllegalArgumentException( "Requested attribute was not a map" );
	}

	final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
	if ( !PluralAttribute.CollectionType.MAP.equals( pluralAttribute.getCollectionType() ) ) {
		throw new IllegalArgumentException( "Requested attribute was not a map" );
	}

	return (JpaMapJoin<X, K, V>) join( (MapAttribute) attribute, jt );
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:16,代码来源:AbstractFromImpl.java

示例15: fetch

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> JpaFetch<X, Y> fetch(String attributeName, JoinType jt) {
	if ( !canBeFetchSource() ) {
		throw illegalFetch();
	}

	Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
	if ( attribute.isCollection() ) {
		return (JpaFetch<X, Y>) fetch( (PluralAttribute) attribute, jt );
	}
	else {
		return (JpaFetch<X, Y>) fetch( (SingularAttribute) attribute, jt );
	}
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:16,代码来源:AbstractFromImpl.java


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