本文整理汇总了Java中javax.persistence.metamodel.CollectionAttribute类的典型用法代码示例。如果您正苦于以下问题:Java CollectionAttribute类的具体用法?Java CollectionAttribute怎么用?Java CollectionAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollectionAttribute类属于javax.persistence.metamodel包,在下文中一共展示了CollectionAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: join
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的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: copyJoins
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的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;
}
示例3: join
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
@Override
public <Y> JpaCollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection, JoinType jt) {
// if ( !canBeJoinSource() ) {
// throw illegalJoin();
// }
//
// final CollectionJoin<X, Y> join = constructJoin( collection, jt );
// joinScope.addJoin( join );
// return join;
throw new NotYetImplementedException( );
}
示例4: joinCollection
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> JpaCollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) {
final Attribute<X, ?> attribute = (Attribute<X, ?>) locateAttribute( attributeName );
if ( !attribute.isCollection() ) {
throw new IllegalArgumentException( "Requested attribute was not a collection" );
}
final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
if ( !PluralAttribute.CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
throw new IllegalArgumentException( "Requested attribute was not a collection" );
}
return (JpaCollectionJoin<X, Y>) join( (CollectionAttribute) attribute, jt );
}
示例5: postProcessResult
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
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;
}
示例6: get
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
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;
}
示例7: copyFetches
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
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);
}
}
示例8: isTypeOrElementType
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
/**
* Test if attribute is type or in collections has element type
* @param attribute attribute to test
* @param clazz Class to test
* @return true if clazz is asignable from type or element type
*/
public static boolean isTypeOrElementType(Attribute<?, ?> attribute, Class<?> clazz) {
if (attribute.isCollection()) {
return clazz.isAssignableFrom(((CollectionAttribute<?, ?>) attribute).getBindableJavaType());
}
return clazz.isAssignableFrom(attribute.getJavaType());
}
示例9: join
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
@Override
public <Y> CollectionJoin<X, Y> join(
CollectionAttribute<? super X, Y> collection) {
// TODO Auto-generated method stub
return null;
}
示例10: join
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
@Override
<Y> JpaCollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection);
示例11: getCollection
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
return null;
}
示例12: getDeclaredCollection
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
return null;
}
示例13: join
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
@Override
public <Y> CollectionJoin<T, Y> join( CollectionAttribute<? super T, Y> arg0 )
{
// TODO Auto-generated method stub
return null;
}
示例14: literal
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
public static <E, T> CollectionAttribute<E, T> literal(Collection<T> value) {
return PseudoAttribute.Constructors.literal(value);
}
示例15: collectionNull
import javax.persistence.metamodel.CollectionAttribute; //导入依赖的package包/类
public static <E, T> CollectionAttribute<E, T> collectionNull() {
return PseudoAttribute.Constructors.literal((Collection<T>)null);
}