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

项目: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();
}
项目:osiam    文件:ExtensionQueryField.java   
@SuppressWarnings("unchecked")
protected SetJoin<UserEntity, ExtensionFieldValueEntity> createOrGetJoin(String alias, Root<UserEntity> root,
                                                                         SetAttribute<UserEntity, ExtensionFieldValueEntity> attribute) {

    for (Join<UserEntity, ?> currentJoin : root.getJoins()) {
        if (currentJoin.getAlias() == null) {
            // if alias is null, it is not an alias for an extension join, so we ignore it
            continue;
        }

        if (currentJoin.getAlias().equals(alias)) {
            return (SetJoin<UserEntity, ExtensionFieldValueEntity>) currentJoin;
        }
    }

    final SetJoin<UserEntity, ExtensionFieldValueEntity> join = root.join(attribute, JoinType.LEFT);

    join.alias(alias);

    return join;
}
项目:resource-server    文件:ExtensionQueryField.java   
@SuppressWarnings("unchecked")
protected SetJoin<UserEntity, ExtensionFieldValueEntity> createOrGetJoin(String alias, Root<UserEntity> root,
                                                                         SetAttribute<UserEntity, ExtensionFieldValueEntity> attribute) {

    for (Join<UserEntity, ?> currentJoin : root.getJoins()) {
        if (currentJoin.getAlias() == null) {
            // if alias is null, it is not an alias for an extension join, so we ignore it
            continue;
        }

        if (currentJoin.getAlias().equals(alias)) {
            return (SetJoin<UserEntity, ExtensionFieldValueEntity>) currentJoin;
        }
    }

    final SetJoin<UserEntity, ExtensionFieldValueEntity> join = root.join(attribute, JoinType.LEFT);

    join.alias(alias);

    return join;
}
项目: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;
}
项目:oma-riista-web    文件:JpaSpecs.java   
@Nonnull
public static <T, U> Specification<T> inCollection(
        @Nonnull final SetAttribute<? super T, U> setAttribute, @Nullable final Collection<U> values) {

    Objects.requireNonNull(setAttribute, "setAttribute must not be null");

    return (root, query, cb) -> JpaPreds.inCollection(cb, root.join(setAttribute), values);
}
项目:hibernate-semantic-query    文件:AbstractFromImpl.java   
@Override
    public <Y> JpaSetJoin<X, Y> join(SetAttribute<? super X, Y> set, JoinType jt) {
//      if ( !canBeJoinSource() ) {
//          throw illegalJoin();
//      }
//
//      final SetJoin<X, Y> join = constructJoin( set, 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> 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 );
}
项目:u-qasar.platform    文件:MetaDataService.java   
long countUsersWithMetaData(T entity, SetAttribute<User, T> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Long> query = cb.createQuery(Long.class);
    Root<User> root = query.from(User.class);
    Join<User, T> join = root.join(attribute);
    query.where(join.in(entity));
    query.select(cb.countDistinct(root));
    return em.createQuery(query).getSingleResult();
}
项目:u-qasar.platform    文件:MetaDataService.java   
long countQOWithMetaData(T entity, SetAttribute<QMBaseIndicator, QModelTagData> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Long> query = cb.createQuery(Long.class);
    Root<QMQualityObjective> root = query.from(QMQualityObjective.class);
    Join<QMQualityObjective, QModelTagData> join = root.join(attribute);
    query.where(join.get(QModelTagData_.tagId).in(entity.getId()));
    query.select(cb.countDistinct(root));
    return em.createQuery(query).getSingleResult();
}
项目:u-qasar.platform    文件:MetaDataService.java   
long countQIWithMetaData(T entity, SetAttribute<QMBaseIndicator, QModelTagData> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Long> query = cb.createQuery(Long.class);
    Root<QMQualityIndicator> root = query.from(QMQualityIndicator.class);
    Join<QMQualityIndicator, QModelTagData> join = root.join(attribute);
    query.where(join.get(QModelTagData_.tagId).in(entity.getId()));
    query.select(cb.countDistinct(root));
    return em.createQuery(query).getSingleResult();
}
项目:u-qasar.platform    文件:MetaDataService.java   
long countQMetricWithMetaData(T entity, SetAttribute<QMBaseIndicator, QModelTagData> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Long> query = cb.createQuery(Long.class);
    Root<QMMetric> root = query.from(QMMetric.class);
    Join<QMMetric, QModelTagData> join = root.join(attribute);
    query.where(join.get(QModelTagData_.tagId).in(entity.getId()));
    query.select(cb.countDistinct(root));
    return em.createQuery(query).getSingleResult();
}
项目:u-qasar.platform    文件:MetaDataService.java   
long countprojectsWithMetaData(T entity, SetAttribute<Project, T> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Long> query = cb.createQuery(Long.class);
    Root<Project> root = query.from(Project.class);
    Join<Project, T> join = root.join(attribute);
    query.where(join.in(entity));
    query.select(cb.countDistinct(root));
    return em.createQuery(query).getSingleResult();
}
项目:u-qasar.platform    文件:MetaDataService.java   
List<User> getUsersWithMetaData(T entity, SetAttribute<User, T> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<User> query = cb.createQuery(User.class);
    Root<User> root = query.from(User.class);
    Join<User, T> join = root.join(attribute);
    query.where(join.in(entity));
    return em.createQuery(query).getResultList();
}
项目:u-qasar.platform    文件:MetaDataService.java   
List<Project> getProjectsWithMetaData(T entity, SetAttribute<Project, T> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Project> query = cb.createQuery(Project.class);
    Root<Project> root = query.from(Project.class);
    Join<Project, T> join = root.join(attribute);
    query.where(join.in(entity));
    return em.createQuery(query).getResultList();
}
项目:u-qasar.platform    文件:MetaDataService.java   
private List<QMQualityObjective> getQOWithMetaData(T entity, SetAttribute<QMBaseIndicator, QModelTagData> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<QMQualityObjective> query = cb.createQuery(QMQualityObjective.class);
    Root<QMQualityObjective> root = query.from(QMQualityObjective.class);
    Join<QMQualityObjective, QModelTagData> join = root.join(attribute);
    query.where(join.get(QModelTagData_.tagId).in(entity.getId()));
    return em.createQuery(query).getResultList();
}
项目:u-qasar.platform    文件:MetaDataService.java   
private List<QMQualityIndicator> getQIWithMetaData(T entity, SetAttribute<QMBaseIndicator, QModelTagData> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<QMQualityIndicator> query = cb.createQuery(QMQualityIndicator.class);
    Root<QMQualityIndicator> root = query.from(QMQualityIndicator.class);
    Join<QMQualityIndicator, QModelTagData> join = root.join(attribute);
    query.where(join.get(QModelTagData_.tagId).in(entity.getId()));
    return em.createQuery(query).getResultList();
}
项目:u-qasar.platform    文件:MetaDataService.java   
private List<QMMetric> getQMetricWithMetaData(T entity, SetAttribute<QMBaseIndicator, QModelTagData> attribute) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<QMMetric> query = cb.createQuery(QMMetric.class);
    Root<QMMetric> root = query.from(QMMetric.class);
    Join<QMMetric, QModelTagData> join = root.join(attribute);
    query.where(join.get(QModelTagData_.tagId).in(entity.getId()));
    return em.createQuery(query).getResultList();
}
项目:VaadinUtils    文件:FormHelper.java   
public <T extends CustomField<?>> T doBinding(String fieldLabel, SetAttribute<?, ?> field, T customField)
{

    doBinding(group, field.getName(), customField);
    this.fieldList.add(customField);
    form.addComponent(customField);
    return customField;

}
项目:VaadinUtils    文件:FormHelper.java   
/**
 * the set in the parent table that holds the set of children
 * 
 * @param field
 * @return
 */
public TwinColSelectBuilder<L> setField(SetAttribute<E, L> field)
{
    this.field = field.getName();
    listClazz = field.getBindableJavaType();
    return this;
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <J, V> Condition<E> eq(final JoinBuilder<E, J> join, final SetAttribute<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 SetAttribute<? 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 SetAttribute<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 SetAttribute<? 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 <V> Condition<E> in(final SetAttribute<E, V> attribute, final Collection<V> values)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            return root.get(attribute).in(values);
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <V> Condition<E> in(final SetAttribute<E, V> agents, final V agent)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            return root.get(agents).in(agent);
        }
    };
}
项目:VaadinUtils    文件:JpaDslAbstract.java   
public <J, V extends Comparable<? super V>> Condition<E> lessThanOrEqualTo(
        final SetAttribute<? 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" })
private <T> JoinBuilder<E, T> join(final SetAttribute<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 JoinMetaDataSet(attribute, type, fetch));

    return jb;
}
项目:VaadinUtils    文件:JpaDslSubqueryBuilder.java   
/**
 * join on parent.child = child
 * 
 * @param parentAttrib
 * @return
 */
public AbstractCondition<E> joinParentQueryOnParentAttrib(final SetAttribute<P, E> parentAttrib)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            return builder.equal(parentRoot.get(parentAttrib), root);

        }
    };
}
项目:VaadinUtils    文件:JpaDslSubqueryBuilder.java   
/**
 * join on parent = child.parent
 * 
 * @param parentAttrib
 * @return
 */
public AbstractCondition<E> joinParentQueryOnSubAttrib(final SetAttribute<E, P> subQueryAttrib)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            return builder.equal(parentRoot, root.get(subQueryAttrib));

        }
    };
}
项目:VaadinUtils    文件:JpaDslSubqueryBuilder.java   
/**
 * join on parent.someattrib = child.someattrib
 * 
 * @param parentAttrib
 * @param subQueryAttrib
 * @return
 */
public <V> AbstractCondition<E> joinParentQuery(final SingularAttribute<P, V> parentAttrib,
        final SetAttribute<E, V> subQueryAttrib)
{
    return new AbstractCondition<E>()
    {

        @Override
        public Predicate getPredicates()
        {
            return builder.equal(parentRoot.get(parentAttrib), root.get(subQueryAttrib));

        }
    };
}
项目:scoutmaster    文件:SMFormHelper.java   
public <T extends BaseEntity, L, F> TokenField bindTagField(final AbstractLayout form, final FieldGroup group,
        final Selected<T> selected, final String fieldLabel, final SetAttribute<T, L> entityField)
{
    final TokenField field = bindTagField(form, group, selected, fieldLabel, entityField.getName());
    getFieldList().add(field);
    return field;
}
项目:scoutmaster    文件:SMMultiColumnFormLayout.java   
public <L> TokenField bindTagField(final Selected<E> selected, final String fieldLabel,
        final SetAttribute<E, L> entityField)
{
    final TokenField field = ((SMFormHelper<E>) getFormHelper()).bindTagField(this, super.getFieldGroup(), selected,
            fieldLabel, entityField);
    getFieldList().add(field);
    return field;
}
项目: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    文件: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   
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> SetJoin<X, Y> join(SetAttribute<? super X, Y> set) {
    // TODO Auto-generated method stub
    return null;
}
项目:tap17-muggl-javaee    文件:MugglFrom.java   
@Override
public <Y> SetJoin<X, Y> join(SetAttribute<? super X, Y> set, JoinType jt) {
    // TODO Auto-generated method stub
    return null;
}
项目:jhipster    文件:QueryService.java   
protected <OTHER, X> Specification<ENTITY> equalsSetSpecification(SetAttribute<? super ENTITY, OTHER> reference,
    SingularAttribute<OTHER, X> idField,
    X value) {
    return (root, query, builder) -> builder.equal(root.join(reference).get(idField), value);
}