本文整理汇总了Java中javax.persistence.metamodel.ListAttribute类的典型用法代码示例。如果您正苦于以下问题:Java ListAttribute类的具体用法?Java ListAttribute怎么用?Java ListAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListAttribute类属于javax.persistence.metamodel包,在下文中一共展示了ListAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: join
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
@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();
}
示例2: findActive
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
/**
* 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();
}
示例3: castGet
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
@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;
}
}
示例4: copyJoins
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
/**
* @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;
}
示例5: findIdentifiers
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
/**
* 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();
}
示例6: join
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
@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( );
}
示例7: joinList
import javax.persistence.metamodel.ListAttribute; //导入依赖的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 );
}
示例8: eq
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
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);
}
};
}
示例9: equal
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
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);
}
};
}
示例10: greaterThanOrEqualTo
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
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);
}
};
}
示例11: greaterThan
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
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));
}
};
}
示例12: in
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
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);
}
};
}
示例13: lessThanOrEqualTo
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
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);
}
};
}
示例14: JoinBuilder
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
@SuppressWarnings(
{ "unchecked", "rawtypes" })
public JoinBuilder(final ListAttribute<? super E, K> attribute, final JoinType type, final boolean fetch)
{
joins.add(new JoinMetaDataList(attribute, type, fetch));
}
示例15: join
import javax.persistence.metamodel.ListAttribute; //导入依赖的package包/类
@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;
}