Java 类javax.persistence.metamodel.ListAttribute 实例源码

项目:oma-riista-web    文件:CriteriaUtils.java   
@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();
}
项目:darceo    文件:DataFileFormatDaoBean.java   
/**
 * Return active file formats for the given DigitalObject type, filtered by the given migration attribute (only
 * those objects for which the given migration attribute returns an empty result will be checked for formats).
 * 
 * A format is considered active if it is used by a file belonging to the current version of a digital object that
 * has not been migrated from.
 * 
 * @param <T>
 *            type of the digital object
 * @param clazz
 *            class of the digital object
 * @param excludedMigration
 *            migration attribute to check
 * @return list of active file formats
 */
private <T extends DigitalObject> List<DataFileFormat> findActive(Class<T> clazz,
        ListAttribute<? super T, ? extends Migration<?, ?>> excludedMigration) {

    CriteriaQuery<DataFileFormat> query = criteriaBuilder.createQuery(DataFileFormat.class);

    Root<T> root = query.from(clazz);
    query.where(criteriaBuilder.isEmpty(root.<List<?>> get(excludedMigration.getName())));

    Join<T, ContentVersion> joinVersion = root.join(DigitalObject_.currentVersion);
    Join<ContentVersion, DataFileVersion> joinFileVersions = joinVersion.join(ContentVersion_.files);
    Join<DataFileVersion, DataFile> joinFiles = joinFileVersions.join(DataFileVersion_.dataFile);
    query.select(joinFiles.get(DataFile_.format));

    return entityManager.createQuery(query).getResultList();
}
项目:VaadinUtils    文件:JoinBuilder.java   
@SuppressWarnings("unchecked")
private <V> Expression<?> castGet(final Attribute<K, V> attribute, Join<E, K> join)
{
    if (attribute instanceof SingularAttribute)
    {
        return join.get((SingularAttribute<K, V>) attribute);
    }
    else if (attribute instanceof ListAttribute)
    {
        return join.get((ListAttribute<K, V>) attribute);
    }
    else if (attribute instanceof SetAttribute)
    {
        return join.get((SetAttribute<K, V>) attribute);
    }
    else
    {
        return null;
    }
}
项目:query-utils    文件:JpaCriteriaCopy.java   
/**
 * @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;
}
项目:darceo    文件:IdentifierDaoBean.java   
/**
 * Returns the identifiers of digital objects of the given type, whose current version contains at least one data
 * file in a format with the given puid, filtered by the given migration attribute (only those objects for which the
 * given migration attribute returns an empty result will be returned) and optionally filtered by the object owner
 * and the object database id.
 * 
 * @param <T>
 *            type of the digital object
 * @param clazz
 *            class of the digital object
 * @param excludedMigration
 *            migration attribute to check
 * @param puid
 *            data file format puid to look for
 * @param ownerId
 *            digital object owner id; can be <code>null</code>
 * @param objectIds
 *            digital object database identifiers; can be <code>null</code>
 * @return list of digital object identifiers
 */
private <T extends DigitalObject> List<String> findIdentifiers(Class<T> clazz,
        ListAttribute<? super T, ? extends Migration<?, ?>> excludedMigration, String puid, Long ownerId,
        Collection<Long> objectIds) {

    if (objectIds != null && objectIds.isEmpty()) {
        return Collections.emptyList();
    }

    CriteriaQuery<String> query = criteriaBuilder.createQuery(String.class);

    Root<T> root = query.from(clazz);
    Join<T, Identifier> joinIdentifier = root.join(DigitalObject_.defaultIdentifier);

    Join<T, ContentVersion> joinVersion = root.join(DigitalObject_.currentVersion);
    Join<ContentVersion, DataFileVersion> joinFileVersions = joinVersion.join(ContentVersion_.files);
    Join<DataFileVersion, DataFile> joinFiles = joinFileVersions.join(DataFileVersion_.dataFile);
    Join<DataFile, DataFileFormat> joinFormat = joinFiles.join(DataFile_.format);

    Predicate where = criteriaBuilder.and(criteriaBuilder.equal(joinFormat.get(DataFileFormat_.puid), puid),
        criteriaBuilder.isEmpty(root.<List<?>> get(excludedMigration.getName())));

    if (ownerId != null) {
        where = criteriaBuilder.and(where, criteriaBuilder.equal(root.get(DigitalObject_.ownerId), ownerId));
    }

    if (objectIds != null) {
        where = criteriaBuilder.and(where, root.get(DigitalObject_.id).in(objectIds));
    }

    query.select(joinIdentifier.get(Identifier_.identifier));
    query.distinct(true);
    query.where(where);

    return entityManager.createQuery(query).getResultList();
}
项目:hibernate-semantic-query    文件:AbstractFromImpl.java   
@Override
    public <Y> JpaListJoin<X, Y> join(ListAttribute<? super X, Y> list, JoinType jt) {
//      if ( !canBeJoinSource() ) {
//          throw illegalJoin();
//      }
//
//      final ListJoin<X, Y> join = constructJoin( list, jt );
//      joinScope.addJoin( join );
//      return join;

        throw new NotYetImplementedException(  );
    }
项目:hibernate-semantic-query    文件:AbstractFromImpl.java   
@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 );
    }
}
项目:hibernate-semantic-query    文件:AbstractFromImpl.java   
@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 );
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <J, V> Condition<E> eq(final JoinBuilder<E, J> join, final ListAttribute<J, V> field, final V value)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            return builder.equal(getJoin(join).get(field), value);
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <J, V> Condition<E> equal(final ListAttribute<? super E, J> joinAttribute, final JoinType joinType,
        final SingularAttribute<J, V> field, final V value)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            Join<E, J> join = getJoin(joinAttribute, joinType);
            return builder.equal(join.get(field), value);
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <L> Condition<E> equal(final ListAttribute<E, L> field, final L value)
{

    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            return builder.equal(root.get(field), value);
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <J, V extends Comparable<? super V>> Condition<E> greaterThanOrEqualTo(
        final ListAttribute<? super E, J> joinAttribute, final JoinType joinType,
        final SingularAttribute<J, V> field, final V value)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            Join<E, J> join = getJoin(joinAttribute, joinType);
            return builder.greaterThanOrEqualTo(join.get(field), value);
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <J, V extends Comparable<? super V>> Condition<E> greaterThan(
        final ListAttribute<? super E, J> joinAttribute, final JoinType joinType,
        final SingularAttribute<J, V> field, final SingularAttribute<E, V> value)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            Join<E, J> join = getJoin(joinAttribute, joinType);
            return builder.greaterThan(join.get(field), root.get(value));
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <J, V extends Comparable<? super V>> Condition<E> greaterThanOrEqualTo(
        final ListAttribute<? super E, J> joinAttribute, final JoinType joinType,
        final SingularAttribute<J, V> field, final SingularAttribute<E, V> value)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            Join<E, J> join = getJoin(joinAttribute, joinType);
            return builder.greaterThanOrEqualTo(join.get(field), root.get(value));
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <V, K> Condition<E> in(final JoinBuilder<E, V> join, final ListAttribute<V, K> attribute,
        final Collection<K> values)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            return getJoin(join).get(attribute).in(values);
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <J, V extends Comparable<? super V>> Condition<E> lessThanOrEqualTo(
        final ListAttribute<? super E, J> joinAttribute, final JoinType joinType,
        final SingularAttribute<J, V> field, final V value)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            Join<E, J> join = getJoin(joinAttribute, joinType);
            return builder.lessThanOrEqualTo(join.get(field), value);
        }
    };
}
项目:VaadinUtils    文件:JoinBuilder.java   
@SuppressWarnings(
{ "unchecked", "rawtypes" })
public JoinBuilder(final ListAttribute<? super E, K> attribute, final JoinType type, final boolean fetch)
{
    joins.add(new JoinMetaDataList(attribute, type, fetch));

}
项目:VaadinUtils    文件:JoinBuilder.java   
@SuppressWarnings(
{ "unchecked", "rawtypes" })
private <T> JoinBuilder<E, T> join(final ListAttribute<K, T> attribute, final JoinType type, final boolean fetch)
{
    final JoinBuilder<E, T> jb = new JoinBuilder<E, T>();
    jb.joins.addAll(joins);
    jb.joins.add(new JoinMetaDataList(attribute, type, fetch));

    return jb;
}
项目:query-utils    文件:ProjectionResultUtil.java   
static Object postProcessResult(Class<?> constructorParameterType, Attribute<?, ?> attr, List<Object> val) {
    logger.debug("postProcessResult({},{},{})", new Object[] {constructorParameterType, attr, val});
    Object ret;
    if (attr instanceof SingularAttribute) {
        if (!isRequiredByQueryAttribute(attr) && val.isEmpty()) {
            logger.debug("Optional SingularAttribute and empty resultList, returning null to be later replaced by None()");
            ret = null;
        } else {
            if (val.size() != 1) {
                throw new IllegalArgumentException("Collection expected to be of size " + 1 + " but was: " + val + " for: " + attr.getName());
            }
            ret = head(val);
        }
    } else {
        if (constructorParameterType.equals(ArrayList.class)) {
            logger.debug("Constructor expecting an ArrayList: {}", constructorParameterType.getName());
            ret = val instanceof ArrayList ? val : new ArrayList<Object>(val);
        } else if (constructorParameterType.equals(List.class) || constructorParameterType.equals(Object.class) && attr instanceof ListAttribute) {
            logger.debug("Constructor expecting a List: {}", constructorParameterType.getName());
            ret = val;
        } else if (constructorParameterType.equals(Collection.class) || constructorParameterType.equals(Object.class) && attr instanceof CollectionAttribute) {
            logger.debug("Constructor expecting a Collection: {}", constructorParameterType.getName());
            ret = val;
        } else if (constructorParameterType.equals(SortedSet.class) || constructorParameterType.equals(TreeSet.class)) {
            logger.debug("Constructor expecting a SortedSet: {}", constructorParameterType.getName());
            ret = new TreeSet<Object>(val);
        } else if (constructorParameterType.equals(Set.class) || constructorParameterType.equals(Object.class) && attr instanceof SetAttribute) {
            logger.debug("Constructor expecting a Set: {}", constructorParameterType.getName());
            ret = newSet(val);
        } else {
            ret = val;
        }
        if (((Collection<?>)ret).size() != val.size()) {
            logger.info("size of a Set/SortedSet was different from the size of the originating data! Have you maybe suboptimally implemented equals/compareTo? Enable debug logging for stack trace. Attribute: {}, List: {}, Set: {}", attr, val, ret);
            logger.debug("size of a Set/SortedSet... stack: ", new Exception());
        }
    }
    logger.debug("postProcessResult -> {}", ret);
    return ret;
}
项目:query-utils    文件:ProjectionHelper.java   
private void setListAttributeOrderings(Attribute<?, ?> target, CriteriaQuery<Object[]> query, Map<Attribute<?, ?>, From<?, ?>> actualJoins) {
    if (target instanceof JoiningAttribute) {
        logger.debug("Adding orderings based on ListAttributes");
        for (Attribute<?, ?> a: ((JoiningAttribute) target).getAttributes()) {
            setListAttributeOrderings(a, query, actualJoins);
        }
    } else if (target instanceof ListAttribute) {
        addListAttributeOrdering(query, actualJoins.get(target), resolveOrderColumn((ListAttribute<?,?>)target), em.apply().getCriteriaBuilder());
    }
}
项目:query-utils    文件:QueryUtils.java   
public static Expression<?> get(Path<?> path, Attribute<?,?> attr) {
    @SuppressWarnings({ "rawtypes", "unchecked" })
    Expression<?> ret = attr instanceof SingularAttribute ? path.get((SingularAttribute) attr) :
                        attr instanceof CollectionAttribute ? path.get((CollectionAttribute) attr) :
                        attr instanceof SetAttribute ? path.get((SetAttribute) attr) :
                        attr instanceof ListAttribute ? path.get((ListAttribute) attr) :
                        attr instanceof MapAttribute ? path.get((PluralAttribute) attr) :
                                                       path.get((CollectionAttribute) attr);
    return ret;
}
项目:query-utils    文件:JpaCriteriaCopy.java   
public void copyCriteriaWithoutSelect(CriteriaQuery<?> from, CriteriaQuery<?> to, CriteriaBuilder cb) {
    int counter = findLatestCustomAlias(from).getOrElse(0);
    for (Root<?> root : sort(comparator, from.getRoots())) {
        Root<?> r = to.from(root.getJavaType());
        copyAlias(root, r, ++counter);
        counter = copyJoins(root, r, ++counter);
    }
    to.distinct(from.isDistinct());
    if (from.getGroupList() != null) {
        to.groupBy(from.getGroupList());
    }
    if (from.getGroupRestriction() != null) {
        to.having(from.getGroupRestriction());
    }
    if (from.getRestriction() != null) {
        to.where(from.getRestriction());
    }

    if (from.getOrderList() != null && !from.getOrderList().isEmpty()) {
        to.orderBy(from.getOrderList());
    } else {
        Selection<?> selection = QueryUtils.resolveSelection(from, to);
        if (selection.isCompoundSelection()) {
            for (Selection<?> s: selection.getCompoundSelectionItems()) {
                if (s instanceof Path<?> && ((Path<?>)s).getModel() instanceof ListAttribute) {
                    addListAttributeOrdering(to, (Expression<?>) s, resolveOrderColumn((ListAttribute<?,?>)((Path<?>)s).getModel()), cb);
                }
            }
        } else if (selection instanceof Path<?> && ((Path<?>)selection).getModel() instanceof ListAttribute) {
            addListAttributeOrdering(to, (Expression<?>) selection, resolveOrderColumn((ListAttribute<?,?>)((Path<?>)selection).getModel()), cb);
        }
    }
}
项目:query-utils    文件:JpaCriteriaCopy.java   
private static void copyFetches(FetchParent<?, ?> from, FetchParent<?, ?> to) {
    for (Fetch<?, ?> fetch : sort(fetchComparator, from.getFetches())) {
        Attribute<?, ?> attr = fetch.getAttribute();
        @SuppressWarnings({ "rawtypes", "unchecked" })
        Fetch<?, ?> f = attr instanceof SingularAttribute ? to.fetch((SingularAttribute) fetch.getAttribute(), fetch.getJoinType()) :
            attr instanceof CollectionAttribute ? to.fetch((CollectionAttribute) fetch.getAttribute(), fetch.getJoinType()) :
            attr instanceof SetAttribute ? to.fetch((SetAttribute) fetch.getAttribute(), fetch.getJoinType()) :
            attr instanceof ListAttribute ? to.fetch((ListAttribute) fetch.getAttribute(), fetch.getJoinType()) :
            attr instanceof MapAttribute ? to.fetch((MapAttribute) fetch.getAttribute(), fetch.getJoinType()) :
            to.fetch((CollectionAttribute) fetch.getAttribute(), fetch.getJoinType());
        copyFetches(fetch, f);
    }
}
项目:tap17-muggl-javaee    文件:MugglFrom.java   
@Override
public <Y> ListJoin<X, Y> join(ListAttribute<? super X, Y> list) {
    // TODO Auto-generated method stub
    return null;
}
项目:tap17-muggl-javaee    文件:MugglFrom.java   
@Override
public <Y> ListJoin<X, Y> join(ListAttribute<? super X, Y> list,
        JoinType jt) {
    // TODO Auto-generated method stub
    return null;
}
项目:hibernate-semantic-query    文件:JpaFrom.java   
@Override
<Y> JpaListJoin<X, Y> join(ListAttribute<? super X, Y> list);
项目:hibernate-semantic-query    文件:JpaFrom.java   
@Override
<Y> JpaListJoin<X, Y> join(ListAttribute<? super X, Y> list, JoinType jt);
项目:hibernate-semantic-query    文件:AbstractFromImpl.java   
@Override
public <Y> JpaListJoin<X, Y> join(ListAttribute<? super X, Y> list) {
    return join( list, DEFAULT_JOIN_TYPE );
}
项目:olingo-odata2    文件:JPAEntityTypeMock.java   
@Override
public ListAttribute<X, ?> getDeclaredList(final String arg0) {
  return null;
}
项目:olingo-odata2    文件:JPAEntityTypeMock.java   
@Override
public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
  return null;
}
项目:olingo-odata2    文件:JPAEntityTypeMock.java   
@Override
public ListAttribute<? super X, ?> getList(final String arg0) {
  return null;
}
项目:olingo-odata2    文件:JPAEntityTypeMock.java   
@Override
public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
  return null;
}
项目:olingo-odata2    文件:JPAManagedTypeMock.java   
@Override
public ListAttribute<X, ?> getDeclaredList(final String arg0) {
  return null;
}
项目:olingo-odata2    文件:JPAManagedTypeMock.java   
@Override
public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
  return null;
}
项目:olingo-odata2    文件:JPAManagedTypeMock.java   
@Override
public ListAttribute<? super X, ?> getList(final String arg0) {
  return null;
}
项目:olingo-odata2    文件:JPAManagedTypeMock.java   
@Override
public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
  return null;
}
项目:olingo-odata2    文件:JPAEmbeddableTypeMock.java   
@Override
public ListAttribute<X, ?> getDeclaredList(final String arg0) {
  return null;
}
项目:olingo-odata2    文件:JPAEmbeddableTypeMock.java   
@Override
public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
  return null;
}
项目:olingo-odata2    文件:JPAEmbeddableTypeMock.java   
@Override
public ListAttribute<? super X, ?> getList(final String arg0) {
  return null;
}
项目:olingo-odata2    文件:JPAEmbeddableTypeMock.java   
@Override
public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
  return null;
}