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


Java Attribute.getJavaType方法代码示例

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


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

示例1: byPattern

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
/**
 * Lookup entities having at least one String attribute matching the passed sp's pattern
 */
@SuppressWarnings("unused")
public <T> Predicate byPattern(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder, final SearchParameters sp, final Class<T> type) {
    if (!sp.hasSearchPattern()) {
        return null;
    }

    List<Predicate> predicates = newArrayList();
    EntityType<T> entity = em.getMetamodel().entity(type);
    String pattern = sp.getSearchPattern();

    for (Attribute<T, ?> attr : entity.getDeclaredSingularAttributes()) {
        if (attr.getPersistentAttributeType() == MANY_TO_ONE || attr.getPersistentAttributeType() == ONE_TO_ONE) {
            continue;
        }

        if (attr.getJavaType() == String.class) {
            predicates.add(JpaUtil.stringPredicate(root.get(attribute(entity, attr)), pattern, sp, builder));
        }
    }

    return JpaUtil.orPredicate(builder, predicates);
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:26,代码来源:ByPatternUtil.java

示例2: visit

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
public boolean visit(JpqlPath node, Set<TypeDefinition> typeDefinitions) {
    Alias alias = new Alias(node.jjtGetChild(0).getValue());
    Class<?> type = getType(alias, typeDefinitions);
    for (int i = 1; i < node.jjtGetNumChildren(); i++) {
        ManagedType<?> managedType = forModel(metamodel).filter(type);
        String attributeName = node.jjtGetChild(i).getValue();
        Attribute<?, ?> attribute = managedType.getAttribute(attributeName);
        if (attribute instanceof SingularAttribute
            && ((SingularAttribute<?, ?>)attribute).getType().getPersistenceType() == PersistenceType.BASIC
            && i < node.jjtGetNumChildren() - 1) {
            String error = "Cannot navigate through simple property "
                    + attributeName + " in class " + type.getName();
            throw new PersistenceException(error);
        }
        type = attribute.getJavaType();
    }
    return false;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:19,代码来源:MappingEvaluator.java

示例3: verifyPath

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
public void verifyPath(List<Attribute<?, ?>> path) {
    List<Attribute<?, ?>> attributes = newArrayList(path);
    Class<?> from = null;
    if (attributes.get(0).isCollection()) {
        from = ((PluralAttribute) attributes.get(0)).getElementType().getJavaType();
    } else {
        from = attributes.get(0).getJavaType();
    }
    attributes.remove(0);
    for (Attribute<?, ?> attribute : attributes) {
        if (!attribute.getDeclaringType().getJavaType().isAssignableFrom(from)) {
            throw new IllegalStateException("Wrong path.");
        }
        from = attribute.getJavaType();
    }
}
 
开发者ID:jaxio,项目名称:javaee-lab,代码行数:17,代码来源:JpaUtil.java

示例4: toAttributes

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
public List<Attribute<?, ?>> toAttributes(String path, Class<?> from) {
    try {
        List<Attribute<?, ?>> attributes = newArrayList();
        Class<?> current = from;
        for (String pathItem : Splitter.on(".").split(path)) {
            Class<?> metamodelClass = getCachedClass(current);
            Field field = metamodelClass.getField(pathItem);
            Attribute<?, ?> attribute = (Attribute<?, ?>) field.get(null);
            attributes.add(attribute);
            if (attribute instanceof PluralAttribute) {
                current = ((PluralAttribute<?, ?, ?>) attribute).getElementType().getJavaType();
            } else {
                current = attribute.getJavaType();
            }
        }
        return attributes;
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:jaxio,项目名称:javaee-lab,代码行数:21,代码来源:MetamodelUtil.java

示例5: verifyPath

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
private void verifyPath(List<Attribute<?, ?>> attributes) {
    Class<?> from = attributes.get(0).getJavaType();
    attributes.remove(0);
    for (Attribute<?, ?> attribute : attributes) {
        if (!attribute.getDeclaringType().getJavaType().isAssignableFrom(from)) {
            throw new IllegalStateException("Wrong path.");
        }
        from = attribute.getJavaType();
    }
}
 
开发者ID:antoniomaria,项目名称:karaf4-eclipselink-jpa,代码行数:11,代码来源:PropertySelector.java

示例6: getAttributeClass

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
public static Class<?> getAttributeClass(final Attribute<?, ?> attribute) {
    if (attribute == null) {
        throw new NullPointerException(ATTRIBUTE_CANNOT_BE_NULL);
    }
    if (attribute instanceof PluralAttribute) {
        return ((PluralAttribute) attribute).getBindableJavaType();
    }
    return attribute.getJavaType();
}
 
开发者ID:kuros,项目名称:random-jpa,代码行数:10,代码来源:AttributeHelper.java

示例7: getJavaType

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
private Class getJavaType(DataFetchingEnvironment environment, Argument argument) {
    Attribute argumentEntityAttribute = getAttribute(environment, argument);

    if (argumentEntityAttribute instanceof PluralAttribute)
        return ((PluralAttribute) argumentEntityAttribute).getElementType().getJavaType();

    return argumentEntityAttribute.getJavaType();
}
 
开发者ID:jcrygier,项目名称:graphql-jpa,代码行数:9,代码来源:JpaDataFetcher.java


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