javax.persistence.metamodel.CollectionAttribute Java Examples

The following examples show how to use javax.persistence.metamodel.CollectionAttribute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractFromImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private <Y> CollectionJoinImplementor<X, Y> constructJoin(
		CollectionAttribute<? super X, Y> collection,
		JoinType jt) {
	if ( jt.equals( JoinType.RIGHT ) ) {
		throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
	}

	// TODO : runtime check that the attribute in fact belongs to this From's model/bindable

	final Class<Y> attributeType = collection.getBindableJavaType();
	return new CollectionAttributeJoin<X, Y>(
			criteriaBuilder(),
			attributeType,
			this,
			collection,
			jt
	);
}
 
Example #2
Source File: JpaUtils.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #3
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked" })
public CollectionAttribute<? super X, ?> getCollection(String name) {
	PluralAttribute<? super X, ?, ?> attribute = getPluralAttribute( name );
	if ( attribute == null && getSupertype() != null ) {
		attribute = getSupertype().getPluralAttribute( name );
	}
	basicCollectionCheck( attribute, name );
	return ( CollectionAttribute<X, ?> ) attribute;
}
 
Example #4
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings( "unchecked")
public CollectionAttribute<X, ?> getDeclaredCollection(String name) {
	final PluralAttribute<X,?,?> attribute = declaredPluralAttributes.get( name );
	basicCollectionCheck( attribute, name );
	return ( CollectionAttribute<X, ?> ) attribute;
}
 
Example #5
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked" })
public <E> CollectionAttribute<? super X, E> getCollection(String name, Class<E> elementType) {
	PluralAttribute<? super X, ?, ?> attribute = declaredPluralAttributes.get( name );
	if ( attribute == null && getSupertype() != null ) {
		attribute = getSupertype().getPluralAttribute( name );
	}
	checkCollectionElementType( attribute, name, elementType );
	return ( CollectionAttribute<? super X, E> ) attribute;
}
 
Example #6
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <E> CollectionAttribute<X, E> getDeclaredCollection(String name, Class<E> elementType) {
	final PluralAttribute<X,?,?> attribute = declaredPluralAttributes.get( name );
	checkCollectionElementType( attribute, name, elementType );
	return ( CollectionAttribute<X, E> ) attribute;
}
 
Example #7
Source File: AbstractFromImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> Join<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 (Join<X, Y>) join( (CollectionAttribute) attribute, jt );
		}
		else if ( PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
			return (Join<X, Y>) join( (ListAttribute) attribute, jt );
		}
		else if ( PluralAttribute.CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
			return (Join<X, Y>) join( (SetAttribute) attribute, jt );
		}
		else {
			return (Join<X, Y>) join( (MapAttribute) attribute, jt );
		}
	}
	else {
		return (Join<X, Y>) join( (SingularAttribute) attribute, jt );
	}
}
 
Example #8
Source File: AbstractFromImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
public <X, Y> CollectionJoin<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 (CollectionJoin<X, Y>) join( (CollectionAttribute) attribute, jt );
}
 
Example #9
Source File: CollectionAttributeJoin.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public CollectionAttributeJoin(
		CriteriaBuilderImpl criteriaBuilder,
		Class<E> javaType,
		PathSource<O> pathSource,
		CollectionAttribute<? super O, E> joinAttribute,
		JoinType joinType) {
	super( criteriaBuilder, javaType, pathSource, joinAttribute, joinType );
}
 
Example #10
Source File: CollectionAttributeJoin.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public TreatedCollectionAttributeJoin(CollectionAttributeJoin<O, ? super T> original, Class<T> treatAsType) {
	super(
			original.criteriaBuilder(),
			treatAsType,
			original.getPathSource(),
			(CollectionAttribute<? super O, T>) original.getAttribute(),
			original.getJoinType()
	);
	this.original = original;
	this.treatAsType = treatAsType;
}
 
Example #11
Source File: JPAManagedTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0,
    final Class<E> arg1) {
  return null;
}
 
Example #12
Source File: JPAEmbeddableMock.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
  return null;
}
 
Example #13
Source File: JPAManagedTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
  return null;
}
 
Example #14
Source File: JPAManagedTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<? super X, E> getCollection(final String arg0,
    final Class<E> arg1) {
  return null;
}
 
Example #15
Source File: JPAManagedTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
  return null;
}
 
Example #16
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0,
    final Class<E> arg1) {
  return null;
}
 
Example #17
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
  return null;
}
 
Example #18
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<? super X, E> getCollection(final String arg0,
    final Class<E> arg1) {
  return null;
}
 
Example #19
Source File: JPAEntityTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
  return null;
}
 
Example #20
Source File: JPAEmbeddableTypeMock.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
  return null;
}
 
Example #21
Source File: JPAEmbeddableTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
  return null;
}
 
Example #22
Source File: JPAEmbeddableTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<? super X, E> getCollection(final String arg0,
    final Class<E> arg1) {
  return null;
}
 
Example #23
Source File: JPAEmbeddableTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
  return null;
}
 
Example #24
Source File: JPAEmbeddableTypeMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0,
    final Class<E> arg1) {
  return null;
}
 
Example #25
Source File: JPAEmbeddableMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
  return null;
}
 
Example #26
Source File: JPAEmbeddableMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<? super X, E> getCollection(final String arg0,
    final Class<E> arg1) {
  return null;
}
 
Example #27
Source File: JPAEmbeddableMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
  return null;
}
 
Example #28
Source File: JPAEmbeddableMock.java    From cloud-odata-java with Apache License 2.0 4 votes vote down vote up
@Override
public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0,
    final Class<E> arg1) {
  return null;
}
 
Example #29
Source File: QueryCriteria.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Override
public <P, E> Criteria<C, R> join(CollectionAttribute<? super C, P> att, Criteria<P, P> criteria)
{
    add(new JoinBuilder<C, P, E>(criteria, joinType, att));
    return this;
}
 
Example #30
Source File: JoinBuilder.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public JoinBuilder(Criteria<R, R> criteria, JoinType joinType, CollectionAttribute<? super P, R> collection)
{
    this(criteria, joinType);
    this.collection = collection;
}