Java 类javax.persistence.metamodel.CollectionAttribute 实例源码
项目: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();
}
项目: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;
}
项目:hibernate-semantic-query
文件:AbstractFromImpl.java
@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( );
}
项目: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> 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 );
}
项目: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);
}
}
项目:jdal
文件:JpaUtils.java
/**
* 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());
}
项目:tap17-muggl-javaee
文件:MugglFrom.java
@Override
public <Y> CollectionJoin<X, Y> join(
CollectionAttribute<? super X, Y> collection) {
// TODO Auto-generated method stub
return null;
}
项目:tap17-muggl-javaee
文件:MugglFrom.java
@Override
public <Y> CollectionJoin<X, Y> join(
CollectionAttribute<? super X, Y> collection, JoinType jt) {
// TODO Auto-generated method stub
return null;
}
项目:hibernate-semantic-query
文件:JpaFrom.java
@Override
<Y> JpaCollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection);
项目:hibernate-semantic-query
文件:JpaFrom.java
@Override
<Y> JpaCollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection, JoinType jt);
项目:hibernate-semantic-query
文件:AbstractFromImpl.java
@Override
public <Y> JpaCollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection) {
return join( collection, DEFAULT_JOIN_TYPE );
}
项目:olingo-odata2
文件:JPAEntityTypeMock.java
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAEntityTypeMock.java
@Override
public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAEntityTypeMock.java
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAEntityTypeMock.java
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAManagedTypeMock.java
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAManagedTypeMock.java
@Override
public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAManagedTypeMock.java
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAManagedTypeMock.java
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAEmbeddableTypeMock.java
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAEmbeddableTypeMock.java
@Override
public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAEmbeddableTypeMock.java
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAEmbeddableTypeMock.java
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAEmbeddableMock.java
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAEmbeddableMock.java
@Override
public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAEmbeddableMock.java
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAEmbeddableMock.java
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
return null;
}
项目:hexa.tools
文件:RootImpl.java
@Override
public <Y> CollectionJoin<T, Y> join( CollectionAttribute<? super T, Y> arg0 )
{
// TODO Auto-generated method stub
return null;
}
项目:hexa.tools
文件:RootImpl.java
@Override
public <Y> CollectionJoin<T, Y> join( CollectionAttribute<? super T, Y> arg0, JoinType arg1 )
{
// TODO Auto-generated method stub
return null;
}
项目:raidenjpa
文件:RaidenRoot.java
@Override
public <Y> CollectionJoin<X, Y> join(
CollectionAttribute<? super X, Y> collection) {
// TODO Auto-generated method stub
return null;
}
项目:raidenjpa
文件:RaidenRoot.java
@Override
public <Y> CollectionJoin<X, Y> join(
CollectionAttribute<? super X, Y> collection, JoinType jt) {
// TODO Auto-generated method stub
return null;
}
项目:query-utils
文件:Select.java
public static <E, T> CollectionAttribute<E, T> literal(Collection<T> value) {
return PseudoAttribute.Constructors.literal(value);
}
项目:query-utils
文件:Select.java
public static <E, T> CollectionAttribute<E, T> collectionNull() {
return PseudoAttribute.Constructors.literal((Collection<T>)null);
}
项目:query-utils
文件:Related.java
public static <E,Y,R, A1 extends Attribute<E,?> & Bindable<Y>>
CollectionAttribute<E, R> collection(A1 a1, CollectionAttribute<? super Y,R> a2) {
return JoiningAttribute.Constructors.collection(a1, a2);
}
项目:query-utils
文件:Related.java
public static <E,Y,Y2,R, A1 extends Attribute<E,?> & Bindable<Y>, A2 extends Attribute<? super Y,?> & Bindable<Y2>>
CollectionAttribute<E, R> collection(A1 a1, A2 a2, CollectionAttribute<? super Y2,R> a3) {
return JoiningAttribute.Constructors.collection(a1, a2, a3);
}
项目:query-utils
文件:Related.java
public static <E,Y,Y2,Y3,R, A1 extends Attribute<E,?> & Bindable<Y>, A2 extends Attribute<? super Y,?> & Bindable<Y2>, A3 extends Attribute<? super Y2,?> & Bindable<Y3>>
CollectionAttribute<E, R> collection(A1 a1, A2 a2, A3 a3, CollectionAttribute<? super Y3,R> a4) {
return JoiningAttribute.Constructors.collection(a1, a2, a3, a4);
}
项目:query-utils
文件:Related.java
public static <E,Y,Y2,Y3,Y4,R, A1 extends Attribute<E,?> & Bindable<Y>, A2 extends Attribute<? super Y,?> & Bindable<Y2>, A3 extends Attribute<? super Y2,?> & Bindable<Y3>, A4 extends Attribute<? super Y3,?> & Bindable<Y4>>
CollectionAttribute<E, R> collection(A1 a1, A2 a2, A3 a3, A4 a4, CollectionAttribute<? super Y4,R> a5) {
return JoiningAttribute.Constructors.collection(a1, a2, a3, a4, a5);
}