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


Java Attribute.getPersistentAttributeType方法代码示例

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


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

import javax.persistence.metamodel.Attribute; //导入方法依赖的package包/类
public static String extractNativeSqlColumnName(final Attribute<?, ?> attr) {
    switch (attr.getPersistentAttributeType()) {
    case BASIC:
    case EMBEDDED:
        return attr.getName();
    case ELEMENT_COLLECTION:
    case ONE_TO_ONE:
    case MANY_TO_ONE:
        return attr.getName() + ID_SUFFIX;
    case MANY_TO_MANY:
    case ONE_TO_MANY:
        throw new IllegalArgumentException(PersistentAttributeType.class.getSimpleName() + " ["
                + attr.getPersistentAttributeType() + "] is not supported!");
    default:
        throw UnknownArgumentException.newInstance(PersistentAttributeType.class, attr.getPersistentAttributeType());
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:18,代码来源:Attributes.java

示例4: getExpression

import javax.persistence.metamodel.Attribute; //导入方法依赖的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


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